Closed edbeeching closed 6 months ago
You are right. The AiController3D
is a child of the player and -rotation.y
will always be 0.
But I was thinking if we could simplify this code a bit by using the global position of the goal and making it local to the player. Would something like this work?
var goal_vector = Vector3.ZERO
if _player.next == 0:
goal_distance = _player.position.distance_to(_player.first_jump_pad.position)
goal_vector = _player.first_jump_pad.global_position
if _player.next == 1:
goal_distance = _player.position.distance_to(_player.second_jump_pad.position)
goal_vector = _player.second_jump_pad.global_position
goal_vector = _player.to_local(goal_vector).normalized()
Maybe this would make the code easier to read.
Sounds good, I made a PR #26 if you can review.
fixed in #26
Hey @metinc , I was wondering what you think about this line in the examples refactor. https://github.com/edbeeching/godot_rl_agents_examples/blob/72e4825651f1c9b078c3e7861b56267f78d0b0d6/examples/JumperHard/AIController3D.gd#L25
I think this should be:
What do you think?