#How do you make Ai enemies and pathfinding

1 messages · Page 1 of 1 (latest)

obsidian current
#

I have been looking for videos forever but i cant find it please walk me through it

inland glacierBOT
#
How to ask for help

Following these tips will increase your chance of getting good answers:

Include Details

Helpers need to know as much as possible about your problem. Try answering the following questions:

  • What are you trying to do? (show your node setup / code)
  • What is the expected result?
  • What is happening instead? (include any error messages)
  • What have you tried so far?
Respond to Helpers

Helpers often ask you questions to better understand your problem. Not answering them or saying "it's not relevant" is not helpful. Even if it is not directly relevant, there is a high chance the answer will give more context for the people that are helping you.

Don't be demanding

Please don't expect people to immediately help you. We all do this in our freetime. It may take some time until someone who can help you will answer.

obsidian current
#

ive tried this vid

#

and this

ivory nova
obsidian current
#

every time i follow the instructions of the video the enemy just doesnt follow me

ivory nova
obsidian current
#

i m using an addon rn

ivory nova
# obsidian current i m using an addon rn

I'm not seeing anything about navigation... This is just a player controller script. I'm asking for the code you tried to follow with the tutorial, but wasn't working

obsidian current
#

oh ok

#

extends CharacterBody3D

@export var move_speed: float = 4.0
@onready var navigation_agent: NavigationAgent3D = $NavigationAgent3D

var player: CharacterBody3D = null

func _ready() -> void:
var players = get_tree().get_nodes_in_group("player")[0]

func _process(delta: float) -> void:
navigation_agent.set_target_position(player.global_position)

func _physics_process(delta: float) -> void:
if navigation_agent.is_navigation_finished():
return

    var next_position: Vector3 = navigation_agent.get_next_path_position()
    velocity = global_position.direction_to(next_position) * move_speed



move_and_slide()