0 votes

So I'm working on a top-down PVP game and I think rotating the character according to the position of your right joystick is pretty cool!

I've defined a point that is moved by the (respective) right joystick axises. I want to rotate the character towards that point (which is controlled by your right joystick) but the player (Godot icon) doesn't rotate accordingly.

The workaround was to rotate the character additional e.g. 90° but if I do that the character starts spinning (since I'm adding the rotation in the physic_process - exactly where the rotation is calculated as well).

Thanks for your answers. Sry if I'm overlooking something obvious :)

Edit: I managed to fix the tank canon rotation (I've applied an additional rotation into the tween node call - since I'm interpolating it's rotation). But the question remains: what's the best way of fixing the rotation using "look_at(point)"?

in Engine by (24 points)
edited by

Your image links are broken.

Just realized it :D it's fixed (I hope)

2 Answers

0 votes

So I would need to see your assets and scene structure to be sure, but is the problem just the orientation of the sprite? If you sprite is 90 degrees off, then that would be the source of your problem. look_at should align the sprite to the positive horizontal axis.

In other words, if you replace the godot head with an arrow that points from left to right, is it still 90 degrees off?

Also, if you don't make some rules for deadzones etc, you are going to have some real trouble.

by (116 points)

I have the exact same problem, https://i.imgur.com/rjuDC18.png . Both look at and setting rotation degrees results in my object using the wrong "face". Adding 90 deg seems to solve the problem at the moment. I've not change any default settings of any objects except scale.

Your asset is 90 degrees off. The green triangle should point right not up.

You are right. I just figured it out a second ago.

0 votes

Look at this post : https://godotengine.org/qa/44449/problems-with-rotation-look_at-and-faces-in-2d . It seems like I was overlooking that issue in the same way. I guess it's just a matter of visualizing how degrees work and how they are implemented in the engine.

by (16 points)

I totally agree!

I've already fix the sprite rotation (towards the mouse) by defining a deadzone around the sprite (since the object is spinning if there is no point to rotate to - meaning only the "rotate(radians)" is processed) - I've just realized that recently after debugging.
I fixed the tank canon issue by adding an additional 90° turn in the interpolation method call (but it could be fixed by defining a deadzone as well).

Damn! I've been to focused on whether look_at(Vector2 point) is bugged or not, I didn't even consider these relatively easy workarounds or how to work with this method. Valuable lessons have been learned, thank you very much mate & cheers! :D

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 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 webmaster@godotengine.org with your username.