- Joined
- Jan 11, 2009
- Messages
- 3,414
Alright, i am not sure how to describe this problem to you, but let's give it a go:
Background:
I have a system in my map, dealing wth physics. It works by applying the different forces impacting on an object on a velocity vector, and then applying the velocity vector onto the units position.
Examples of forces impacting on an object are:
*gravity
*thrust
*air/ground friction
Thrust is being applied by multiplying the units rotation vector with a scalar value of the objects acceleration, and then adding that to the velocity.
Rotation is represented by a vector with the length of 1 (a unit vector) pointing in the direction that the unit is facing.
I am trying to apply the force of lift onto airplanes using a certain formula. The formula produces a scalar lift value that is meant to be applied in the relative upwards direction of the object.
This formula is depending on the velocity of the object in it's forwards direction.
Now, my problem is this:
If i use the length of the velocity vector as the speed, i get the speed in the direction the object is moving, not the direction it is facing. The airplane might aswell be falling straight down, and that should not be producing lift!
On the other hand, if i use the scalar value of the planes acceleration, i only get the speed produced by the engine thrust, which is only one of the factors affecting the velocity of the object. What if the airplane is pointing straigt up, but the thrust is weaker than the force of gravity, so that the plane is actually moving downwards?
Is there any way i can find out, how strong the velocity is in the direction the unit is facing?
EDIT: i think i actually imagined this a bit more complicated than it is - if the rotation vector is a unit vector, it should just be enough to multiply the velocity by the rotation, right?
I will just go with this. Let me know if i am wrong.
Background:
I have a system in my map, dealing wth physics. It works by applying the different forces impacting on an object on a velocity vector, and then applying the velocity vector onto the units position.
Examples of forces impacting on an object are:
*gravity
*thrust
*air/ground friction
Thrust is being applied by multiplying the units rotation vector with a scalar value of the objects acceleration, and then adding that to the velocity.
Rotation is represented by a vector with the length of 1 (a unit vector) pointing in the direction that the unit is facing.
I am trying to apply the force of lift onto airplanes using a certain formula. The formula produces a scalar lift value that is meant to be applied in the relative upwards direction of the object.
This formula is depending on the velocity of the object in it's forwards direction.
Now, my problem is this:
If i use the length of the velocity vector as the speed, i get the speed in the direction the object is moving, not the direction it is facing. The airplane might aswell be falling straight down, and that should not be producing lift!
On the other hand, if i use the scalar value of the planes acceleration, i only get the speed produced by the engine thrust, which is only one of the factors affecting the velocity of the object. What if the airplane is pointing straigt up, but the thrust is weaker than the force of gravity, so that the plane is actually moving downwards?
Is there any way i can find out, how strong the velocity is in the direction the unit is facing?
EDIT: i think i actually imagined this a bit more complicated than it is - if the rotation vector is a unit vector, it should just be enough to multiply the velocity by the rotation, right?
I will just go with this. Let me know if i am wrong.