Enemy wont move for some reason

4.1

the navigation is working and the navigation region is working but he wont move?

What is the value for new_velocity?

not changing for some reason

Your target_position doesn’t update, does the enemy move for a little bit and then stop, or never move in general? Seems like the velocity is really high on the Y axis which is strange.

never move in general

I would take a look at next_location. I suspect the value being returned is almost equal to the current position.

1 Like

it is staying the same

next_location staying the same makes sense to me since the enemy doesn’t move.

I am working in 2d, so this code isn’t the same, but this is the core of my seek path finding algorithm:

func seek_position(origin: CharacterBody2D, target_position: Vector2) -> Vector2:
	var steering_force := Vector2.ZERO
	
	var direction: Vector2 = origin.position.direction_to(target_position)
	steering_force = direction * move_speed - origin.velocity
	
	return steering_force

Comparing that to your code I think the problem you are having is in the formula you are using for new_velocity. I suggest trying to calculate the direction to the target and working off of that.

I found this to be invaluable when I first started learning about making enemies move: GitHub - konbel/steering-behaviors-godot-4: Demonstation of simple steering behaviors for autonomous movement

The magnitude of this vector should be impossible, your john_speed is only 25, not 40, what is this print from?

I may have changed the speed

They are calculating the distance (b - a).normalized() is a direction formula from a to b. Godot supplies a.direction_to(b), but that’s not the only way.

1 Like

Good to know, thanks!

if the navigation agent cannot find a path to the target position it will return the parent’s location, could you compare the current_location against the next_location? If they are the same then your agent cannot navigate to that point, your “guy looking for john” node also has a warning, are you sure it’s valid?

I changed guy looking for johns scale

So it is directly 2 meters above the player? Is there a path to it? Maybe it would be more helpful to show the 3D view.


don’t question the texture, the path is updating btw

at least thats what it looks like