Simulate arrow flight
Posted: Tue Aug 28, 2012 4:09 am
Hi All,
I have a 3D game I am working on in XNA using bepu Physics (which has been EXCELLENT so far, thanks Norbo). I am trying to make arrows fly. The arrow's collidable is a Box prefab entity scaled in such a way as to fit the arrow's graphical representation.
I initially set the WorldTransform (and therefore the orientation) of the arrow only when it was first fired. Which is fine if I am only interested in straight line flight paths. But I am now trying to update the orientation of the arrow each frame such that it always heads in the direction of the current (normalized) LinearVelocity vector. I created a lookat matrix for the direction of the velocity and converted it to a quat, and set the orientation to this quat. It didn't work, in some directions the arrow flew sideways, and yawed direction as it dropped (as opposed to pitching). The arrow's world model is transformed straight from the WorldTransform property of its collidable.
The question is: is the linear velocity relative to the orientation of the collidable in any way? (or vice versa, if you like)
All help appreciated
I have a 3D game I am working on in XNA using bepu Physics (which has been EXCELLENT so far, thanks Norbo). I am trying to make arrows fly. The arrow's collidable is a Box prefab entity scaled in such a way as to fit the arrow's graphical representation.
I initially set the WorldTransform (and therefore the orientation) of the arrow only when it was first fired. Which is fine if I am only interested in straight line flight paths. But I am now trying to update the orientation of the arrow each frame such that it always heads in the direction of the current (normalized) LinearVelocity vector. I created a lookat matrix for the direction of the velocity and converted it to a quat, and set the orientation to this quat. It didn't work, in some directions the arrow flew sideways, and yawed direction as it dropped (as opposed to pitching). The arrow's world model is transformed straight from the WorldTransform property of its collidable.
The question is: is the linear velocity relative to the orientation of the collidable in any way? (or vice versa, if you like)
All help appreciated