0 votes

Basically, I want to make the "down" direction go towards a point in space rather than the positive y axis. So for example, if an object is moving in the positive y direction but the "gravity point" is located just to the right of the object, their motion would be converted to the negative x direction from the POV of said point. If the object was moving in the negative y direction but the point was just above them, their motion would be converted to a positive y direction from the point's frame of reference. I'm not sure if this makes any sense but if anyone knows how to do this, it would be greatly appreciated. Thanks! :)

in Engine by (67 points)

maybe draw it, it will be easier to help

1 Answer

0 votes

If you have A and G two vectors (2D or 3D) representing points, the path from A to G is G-A. If G is your center of gravity, you have y = (A-G).normalized(). (Doesn't work if A == G, as you'd divide by 0).

In 2D, x is easy, x = y.rotated(-PI/2).

But in 3D, I would use a Transform. First, get your Transform to the wanted orientation, and then use transform.basis.xform(Vector3.LEFT), and similar. (we use xform on the basis to discard any translation on the Transform).

by (2,684 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.