0 votes

Lets say for example i need to rotate a platform (StaticBody2D) from its center, is there no way to do this in the editor? The pivot points of all my bodys are on 0,0 how do i move them , if i can even do that.

'V' doesn't work on bodys as i have read.

thank you very much!

Godot version 3.2.x
in Engine by (17 points)

Oh, and as a comment following my answer to your question, Control and UI (user interface) nodes do not seem to have the "Center" function. So nodes like text labels, buttons, menus, et cetera, won't be able to have their pivot point offset or centered at all.

1 Answer

+3 votes
Best answer

So I take it that you want to want something like this: https://drive.google.com/file/d/1guT4kFGO99DTsvLd1dQSWoORkff593ZB/view?usp=sharing
Where if you rotate it: https://drive.google.com/file/d/1OuNFDkkV1O8Mz4JIz2ACricljkDn6BL6/view?usp=sharing
It will rotate it around it's center.

Well, all you have to do, is to check that "Centered" option in the sprite.

There is no option like that in StaticBody2D though. It's because StaticBody2D, the way I like to think about it, is basically a position (albeit with other properties).

I imagine your scene might be a bit like this: https://drive.google.com/file/d/1xlGYgK7ltsy6gMvwb4eptZPMQxXyikpC/view?usp=sharing
Where the sprite is offset from the StaticBody2D's Position.

So if you rotate it, it will rotate from the top-left corner (because the axis is the StaticBody's position).

What you want to do is to make sure that both your sprite and collisionshape are perfectly centered on top of your StaticBody2D.

A way you can get a child node (e.g. the chicken sprite and the collisionshape) to be perfectly centered on its parent node is to put it's position to 0, 0. Because it inherits its parent node's position (e.g. the StaticBody2D), 0, 0 for the child node (Chicken Sprite) is exactly where the parent node (StaticBody2D) is, no matter where it is or what position the StaticBody2D is in.

View this short video showcasing the above paragraph: https://drive.google.com/file/d/1vA0ELbnUpVymNCtqXWQF_inmzzqYqVG7/view?usp=sharing

(Sorry for the extremely long answer)

by (204 points)
selected by

Sorry?! About what? Your response was incredible!! Thank you very much, clear and well explained! You are amazing! Even provided pictures AND a video!

Thanks a lot!

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.