-1
\$\begingroup\$

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?

\$\endgroup\$

2 Answers 2

0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

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

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .