Godot Version
4.2.2
Question
Hey there! I want to make that my test_enemy patrol the maze. To do that i use NavigationRegion3D and NavigationAgent3D. NavigationAgent3D is child of test_enemy that have script:
extends CharacterBody3D
@onready var agent = $NavigationAgent3D
var SPEED = 3
var targ : Vector3
signal get_new_target
func _ready():
pass
func _physics_process(delta):
look_at(agent.get_next_path_position())
rotation.x = 0
rotation.z = 0
if position.distance_to(targ) > 0.5:
var curLoc = global_transform.origin
var nextLoc = agent.get_next_path_position()
var newVel = (nextLoc - curLoc).normalized() * SPEED
velocity = newVel
move_and_slide()
else:
emit_signal("get_new_target")
func updateTargetLocation(target):
agent.set_target_position(target)
I cant understand why my test_enemy always banging its head against the wall before he gets the point.
Link to the video: https://www.youtube.com/watch?v=3XGLTYavRPQ
As you can see in the video, navigation mesh is also located on the walls. I would be grateful if you could tell me how to fix it (If, of course, it can cause any problems and is considered incorrect).