将我的身体移动到一个点 [英] Move my body to a point

查看:271
本文介绍了将我的身体移动到一个点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用方块2d。我只是想移动我的身体到这一点。这是最好的方法是什么?

解决方案

当你说你身体,你的意思是你想要施加一个力来获得身体的一个点?



有一个关节鼠标移动,它可能适用于你的情况如果你想拖动身体在iPhone上。它称为鼠标关节,它在这些box2d文档上的8.10以下。



如果你想要一个没有响应它的东西,而是根据它的位置和它去的地方推动事物,去 b2_kinematicBody 相同的文档



希望它有帮助。您的问题非常模糊。



编辑您的问题非常模糊。

cpBodyApplyForce cpBodyApplyImpulse 。有很多方法使用它来将身体移动到一个位置,他们可以得到比我可以在评论中总结更复杂。基本上,你正在进入可以被游戏AI编程源更好地覆盖的东西。



最基本的方法是应用一个多重的力每个轴)从物体到目标位置的距离。如果你想让对象缓慢停止,搜索项AI到达行为可能是一个好主意。我在gamedev.net上找到了此讨论


I am using box 2d. I just want to move my body to the point. What is the best way to do this?

解决方案

When you say you just want to move the body, do you mean you want to apply a force to get the body to a point?

There's a joint designed for mouse movement, and it might work well in your case if you want to drag bodies around on an iPhone. It's called the Mouse Joint, and it's under 8.10 on these box2d docs.

If you want a body that doesn't respond to things hitting it, but pushes things around based on where it is and where it is going, go for the b2_kinematicBody on the same docs

Hope it helps. Your question is very vague.

EDIT in response to comment:

Well, generically the way to do this would be cpBodyApplyForce or cpBodyApplyImpulse. There are many ways to use this to move the body to a position, and they can get more complex than I can summarize in a comment. Essentially, you're getting into stuff that can be better covered by game AI programming sources.

The most basic way would be to apply a force that is some multiple (on each axis) of the distance from the object to the target position. If you want the object to slowly stop, the search terms "AI arrive behavior" might be a good idea. I found this discussion on gamedev.net.

这篇关于将我的身体移动到一个点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆