Jump to content

[1.8] Make Player Look At Nearest Entity


i77_

Recommended Posts

Hi!
I'm trying to make a script that automatically aims at the nearest entity. To do this I subtract the entity's position from the players position, put that through atan to get the angle. Now the part that confuses me is that in minecraft the yaw rotation angle ranges from -180 to 180 degrees, but atan only returns -90 to 90. How am I supposed to implement this properly?
 

EDIT: I also know that I have to add 90 to the angle. This results in the yaw always being positive, making the player do a 180 degree flip at certain positions.

Edited by i77_
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.