rotate 3D character towards player only on the Y-axis

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

I am trying to figure out how to get the target andgle and current angle of my character relative to the player. target angle is the angle that points to the player, current angle is the current angle to origin. this is my code so far:

angle = int(round(rad2deg(get_transform().basis.x.angle_to(Vector3(1,0,0)))))
target_angle = int(round(rad2deg(get_transform().basis.x.angle_to(player.get_translation()))))
print("curent rot", angle)
print("targ rot", target_angle)

I am not sure if I’m doing this correctly, but i want to use this angle and rotate on the y until it is aligned with the target rotation. it seems my curret rotation ad target rotations are incorrect however. :frowning:

Get_node(“.”). transform.basis().y * vector3(0,1,0)

Okan Ozdemir | 2020-04-10 21:18

THANK YOU!! I’ll try This!! :slight_smile:

I AmTired | 2020-04-10 22:08