Quick Question about Vectors

Hi, i got one Vector who need be converted back to the raw force.

This is how the vector is working:

ThisAwesomeVector = Transform.TransformDirection(ThisAwesomeVector)

ThisAwesomeVector looks something like (0.18592, 0f, -0.42398)
How can got it back to (0f, 0f, 5) like in the Force, i want add a 2nd Vector3 who present the relative direction just on x and z.

Like for exemple when i press the W key this vector changes to (0f, 0f, 4), and on the S key we got one (0f, 0f, -4), with A and D the same on the x direction without changing the the original vector3 (ThisAwesomeVector).

Thanks

maybe transform.InverseTransformDirection(vector3);

nope… dont works in my case

you are doing

ThisAwesomeVector = Transform.TransformDirection(ThisAwesomeVector)

but shouldnt it actually be something like

ThisAwesomeVector = myTransform.TransformDirection(ThisAwesomeVector)

(you can also do just transform with the lowercase t).

TransformDirection brings the vector from local space, to world space based on the transform.
InverseTransformDirection brings the vector from world, to the transforms local space, which is what you want.

I never tried it, but maybe you are doing “Transform.InverseTransformDirection”, which might default to world space or something, where you actually want “myTransform.InverseTransformDirection” so that it brings it to the myTransform localSpace (you can also do just transform with the lowercase t).

Well, i try that but it did not work.
What i try to do is when i got force forward, with ore without input to get a bool (imMovingForward) true.

The point is i just looking for the Force Vector, maybe there is a other possible solution to get this working.
But thanks for your help.

Sounds like you are trying to determine the velocity in local space?

Yea, how can i do that?

it should be one of the Inverse functions.

ill try prove it later, but no access to unity atm

Alright, i got it!

ThisAwesomeVector = Transform.InverseTransformVector(MotorForceVector);
Thank you,

1 Like