Getting a direction vector based on the rotation of an object

I’d like to know how to derive a direction vector from an object’s rotation. Say I wanted to fire a projectile in the direction an object is rotated–how would I get the direction that would be applied to a transform for that projectile based on the object’s rotation? Would moving that object change this formula? So, say it is a turret that can rotate, but also move left and right. If the turret keeps the same rotation, but moves right–I want the projectile to fire forward, in the direction the turret is rotated and not be affected by the translation.

Here is a link to a playground that shows the problem I am having.
https://www.babylonjs-playground.com/#04S6Q5

Hope this gives you some ideas https://www.babylonjs-playground.com/#04S6Q5#2

3 Likes

@JohnK Awesome. Tis what I was looking for. Very helpful.

2 Likes