Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #calculate the horizontal angle
- var horizontal_rotation: float = rad2deg(
- Vector2(bot_pos.x, bot_pos.z).angle_to_point(
- Vector2(player_pos.x, player_pos.z))
- + bot_rotation.y) - 90
- #constrain the angle between -180 and 180 to be easyer to use
- if horizontal_rotation < -180:
- horizontal_rotation += 360
- elif horizontal_rotation > 180:
- horizontal_rotation -= 360
- #calculate the vertical angle
- var vertical_rotation: float = rad2deg(
- Vector2(bot_pos.y, bot_pos.z).angle_to_point(
- Vector2(player_pos.y, player_pos.z))
- + bot_rotation.x) - 90
- #and constain it
- if vertical_rotation < -180:
- vertical_rotation += 360
- elif vertical_rotation > 180:
- vertical_rotation -= 360
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement