So I want my turret enemy to look at the player while it's inside an area, the area part is already done but when I use a Tween node, the angle the turret makes to point at the player's global position is not precise at all (photos below)

This is what my turret enemy looks like inside:

And this is the script:

I also tried doing this but didn't work either, it always makes weird angles and it gets even weirded if I move the player AROUND the turret in a circle, it totally doesn't work as I want to.

Any tips?

When tweening or interpolating, you should use the actual angle as the endpoint value, not the difference between angles provided by angle_to.

@xyz said: When tweening or interpolating, you should use the actual angle as the endpoint value, not the difference between angles provided by angle_to.

Sorry what exactly should I do? The actual angle of what node, the turret's or the player's? I'm not very good with the tween :(

Maybe first try to make the simplest version using look_at. Comment out all tween/lerp/global_rotation code and simply use look_at() to orient the node you want to face the player.

node.look_at(player.get_global_position())

@xyz said: Maybe first try to make the simplest version using look_at. Comment out all tween/lerp/global_rotation code and simply use look_at() to orient the node you want to face the player.

node.look_at(player.get_global_position())

Yes I know that! Sorry I didn't explain very well what the problem was. I can make the turret face the player, but I want it to face the player with some DELAY, because with look_at it faces the player INSTANTLY, and I thought using a Tween or using the lerp_angle thing would work but it doesn't work very well, so I'm still stuck

You could exploit look_at() to figure out the wanted orientation angle and then interpolate between current orientation and that orientation using a tween:

var rot_temp = rotation  # save current rotation to temporary
look_at(player.get_global_position())  # rotate using look_at()
var rot_wanted = rotation  # get wanted roatition
rotation = rot_temp  # restore original rotation from temporary

# interpolate from current rotation to wanted rotation using tween
tween.remove_all()
tween.interpolate_property(self, ":rotation", null, rot_wanted, 1.0)
tween.start()
a year later