I am using Libgdx along with Bullet physics. I have a vehicle moving. I would like to use a ray from the vehicles origin and in the vehicles forward direction.

How can I create the forward Vector3 so I can apply it to the ray?

up vote 0 down vote accepted

If you want the ray the vehicle is currently moving upon, you want the difference between the current position and a previous position, then normalize it for the direction of the ray (the start of the ray being the current position). Alternately, you can make a normalized copy of the velocity vector for the direction with and current position as the start of the ray.

thanks for the answer, I'm sure it would have worked perfectly.

however as i was implementing it i came across a Bullet Physics built in function.

BtRayCastVehicle has

vehicle.getForwardVector()

thanks for your help in this matter

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.