Everytime I think I understand it something comes up and I get confused again.
So say I have this code:
var coconutObject : Rigidbody;
var throwForce : float;
function Update () {
if(Input.GetButtonUp("Fire1")){
var newCoconut : Rigidbody = instantiate(coconutObject,transform.position,transform.rotation);
newCoconut.rigidbody.velocity =
transform.TransformDirection(Vector3(0,0, throwForce));
The documentation says it transforms local into world. Alright. But say I’m adding this to an fps controller so and I want it to shoot coconuts in my forward direction. Shouldn’t making it into world space, like the TransformDirection does, always make it always go to the WORLD’S z and not the local z?
So basically no matter where I turn my character, it should always shoot the coconuts in in the same direction, because they’re going forward in the world’s z. But it does the opposite! It shoots the coconuts depending on where I turn, but wouldn’t that be local z? Because unlike the world z, my local z will always change depending on where i’m turning.
Instead, when I DON’T use the TransformDirection, it ALWAYS goes in the same direction.
This has been annoying me for a while now and I really want to get this down so I can better understand what i’m doing with unity.