The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+2 votes

For example what is Godot's equivalent of Unity's Vector3.up?

EDIT : No, wait, shit, I meant the equivalent of transform.up, to get the direction of a rotated object's local up vector.

in Engine by (74 points)
edited by

2 Answers

+5 votes
Best answer

The Vector3's class constants are Godot's global (world) directions. Vector3.UP, Vector3.FORWARD, Vector3.LEFT, etc.
Note that Unity's forward direction is the position Z-axis while Godot's forward direction is the negative Z-axis. The back directions are also inverted.

The local space direction of a 3D node is called Basis and it can be accessed with global_transform.basis.

  • global_transform.basis.x is the local right direction.
  • global_transform.basis.y is the local up direction.
  • global_transform.basis.z is the local back direction.
by (150 points)
selected by

Ok thank you, this is what I needed.

Why isnĀ“t there a linearvelocity.basis? that would be too easy i guess... :D
OK no seriously. How to get a linear
velocity from basis?
I want a script like:

If linear_velocity.z <= -0.2:
<= $tracks...

But if the vehicle/object passes 90 degrees the velocity turns from - to + because its the 3d space z axis. Thats really disturbing. I hope somone can help me there.

+1 vote

I'm not familiar with Unity at all, but according to this it's just a shorthand notation? Godot's uses very similar ones, take a look here: it's Vector3.UP.

Not sure what this has to do with "local space" though...

by (10,604 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.