- Home /
TransformDirection is only working on Y Axis
I am trying to make a bullet object fly forward based on its local rotation on Awake() So far, this works on the bullets local Y Axis, but not on the bullets X or Z Axis This is the code I am trying to use, If you can point out what i am doing wrong, i would appreciate it. Thank you!!
var dir : Vector3 = gameObject.transform.TransformDirection(Vector3.forward);
gameObject.rigidbody.AddForce(dir * speed);
I see nothing wrong with this code, though I've never added force in Awake(). Usually I do it in Start(). Perhaps it is the code that set the initial rotation that has the issue. Post it and the folks on the list can take a look. You can simplify things a bit by using Transform.forward.
Your answer
Follow this Question
Related Questions
Velocity powered rigidbody on a moving platform without parenting. 3 Answers
how do i make rigidbody. velocity follow the objects local rotation? 1 Answer
How to transform velocity to world space before calling controller.move? 1 Answer
Object Speed (transformDirection) 1 Answer
the velocity of a certain direction 1 Answer