#Problem: Enemy can't Clear Jump using Navigation Links (Godot 4.2.2)

4 messages · Page 1 of 1 (latest)

robust bloom
#

I'm trying to make my enemy character jump over a gap to reach me using the Navigation Region and Navigation Links. It jumps, but doesn't try to clear the gap no matter what its velocity is. It's like a force field is preventing it from passing through.
I've included the project along with a small video demonstrating the problem in the zipped folder. I believe only the Enemy and Level0 scenes and scripts should be relevant to the problem. Thank you to anyone who can solve the issue.

(When testing the project press ESC to quit out or tilde key to restart.)

robust bloom
#

Sorry, the first zip was outdated. This is the current one.

robust bloom
#

So, update.....I think I see where the problem may lie. It seems when the enemy reaches the Navigation Link its X and Z velocity go to 0 and stay there. I have no idea why it's do that though; here's the enemy's code as I think it's the only relevant one here.

#

@onready var navigation_agent_3d = $NavigationAgent3D
@export var speed = 30.0
@export var jump_velocity := 5.0
@export var gravity := 9.8
var next_location : Vector3


func _ready():
    navigation_agent_3d.target_reached.connect(give_kiss)
    navigation_agent_3d.link_reached.connect(link_reached)

func _process(_delta):
    var current_location = global_transform.origin
    var new_velocity = (next_location - current_location).normalized() * speed
    next_location = navigation_agent_3d.get_next_path_position()
    
    navigation_agent_3d.set_velocity(new_velocity)
    
func _physics_process(delta):
    if not is_on_floor():
        velocity.y += -gravity * delta
    
    var direction := global_position.direction_to(next_location)
    if direction:
        velocity.x = direction.x * speed
        velocity.z = direction.z * speed

func update_target_location(target_location):
    navigation_agent_3d.set_target_position(target_location)

func give_kiss():
    print("kiss")

func _on_navigation_agent_3d_velocity_computed(safe_velocity):
    velocity = velocity.move_toward(safe_velocity, .25)
    move_and_slide()

func link_reached(_details: Dictionary):
    velocity.y += jump_velocity```