-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a local rotation function to Transform #1788
Comments
I think I could put together a PR for this |
Well, I went an implemented this only to then discover that there's already a |
Aaand never mind, rotate_basis isn't visible in the editor. I'll open a PR to make it visible. |
More comment spam. |
In my opinion it's a must have feature. It's very important to be simple able to rotate objects along it's locally axis. We need something like Use case: Rotate the steering wheel of a vehicle. A wheel with rotation of x: 25 in front of the player and should be rotated along it's local y-axis with a absolute angle. Until waiting for this feature. Do you have an idea to implement this with current stuff? I searched for hours and found no solution. I'm exhausted. |
For something similar, I just used an additional node above what I wanted to rotate. Worked wonders. But yes, I agree that we need this as a function. |
Note that this would be solved by godotengine/godot#55923 which introduces |
Right, wraping in dummy node like Spatial is a good solution/workaround to reset the rotation for the child and rotate it independently. Thanks. I know that. But somehow I didn't think about it at that moment. 🤦♂️ Anyway... we should provide a method for this. I just wonder if we can start with the |
Hy 👋, shouldn't this issue be closed now? |
Indeed, this was superseded by godotengine/godot#55923. Thanks for checking 🙂 |
Describe the project you are working on:
I am working on a 2.5D isometric tactics game.
Describe the problem or limitation you are having in your project:
I wanted to add an input allowing the user to rotate the isometric camera 45 degrees left or right, like you can do in the XCOM series. I naively called
Transform.rotate()
on the Spatial node holding my camera, expecting the node to rotate in place, i.e. to rotate aroundTransform.origin
. Instead, the node rotated around the global origin.It was surprising for me that
rotate
was not a local operation, and that there was a globalrotate
but no localrotate
inTransform
.Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Adding a
Transform.rotate_local()
would make it easier to rotate transforms locally, and make it clear on code-completion which of the rotate functions is local and which isn't.Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
Two implementations of
Transfrom.rotate_local()
come to mind.Multiply the basis by the rotation matrix directly -
var rotationMatrix = getRotationMatrix(axis, rotationDegrees)
transform.basis = transform.basis * rotationMatrix
Alternatively, just call the Basis's
rotated
function.transform.basis = transform.basis.rotated(axis, rotationDegrees)
If this enhancement will not be used often, can it be worked around with a few lines of script?:
This enhancement can be worked around by just rotating the basis of the Transform directly. Adding the enhancement would aim chiefly at making the methods of Transform self-document. A newcomer to Godot can't know if
Transform.rotate()
does a local or a global rotation. But if there's also aTransform.rotate_local()
function, then the purpose of both functions becomes immediately clear.Is there a reason why this should be core and not an add-on in the asset library?:
The purpose of the enhancement is to make the code self-documenting and make it slightly easier to use. This is helpful for everyone, but especially for newer users, who probably don't have add-ons installed.
The text was updated successfully, but these errors were encountered: