Is look_at(Vector2 point) bugged or am I overlooking something? The rotation is off.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By K1NGM4RV

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 :slight_smile:

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)”?

Your image links are broken.

kidscancode | 2019-04-30 16:09

Just realized it :smiley: it’s fixed (I hope)

K1NGM4RV | 2019-04-30 16:12

:bust_in_silhouette: Reply From: iron_weasel

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.

I have the exact same problem, . 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.

arcadeoid | 2019-05-01 16:51

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

iron_weasel | 2019-05-01 17:33

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

arcadeoid | 2019-05-01 17:35

:bust_in_silhouette: Reply From: arcadeoid

Look at this post : . 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.

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! :smiley:

K1NGM4RV | 2019-05-02 15:19