简体   繁体   English

libgdx box2d身体-如何以特定方向匀速移动身体?

[英]libgdx box2d body - How to move body at constant speed with specific direction?

When I touch the screen the body is moving gradually and slowing down when the touch point is near. 当我触摸屏幕时,身体会逐渐移动,而当触摸点靠近时,身体会减速。 My problem is I want to move the body at constant speed let say the given speed is 60 kpH, the body should move starting with speed of 60 kpH until touch point. 我的问题是我想以恒定速度移动身体,假设给定速度为60 kpH,身体应该以60 kpH的速度开始运动直到接触点。 I'm thinking about the solution was on screen touch, get the angle and then move that body using that angle then add the speed to get the right speed? 我在考虑解决方案是在屏幕上触摸,获取角度,然后使用该角度移动该物体,然后增加速度以获得正确的速度?

在此处输入图片说明

I'm not sure if this is the proper way. 我不确定这是否是正确的方法。 But when I use .nor() function at the targetDirection.nor(), the body is now moving at constant speed! 但是当我在targetDirection.nor()上使用.nor()函数时,主体现在正以恒定速度移动! The problem now is when the direction has reached the body is shaking like in a coma. 现在的问题是,当到达方向时,身体像昏迷一样在晃动。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM