# Libgdx, find Vector3 direction

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?

## 2 Answers

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