Before anyone says it, I know… I even feel like a dunce rn, and this test isn’t the best setup.
I can’t, for the life of me, get the location of the player character for my enemy to move towards. For the test, I don’t need the enemy to continuously switch to where the player moves, I just want the enemy to move.
extends RigidBody
export var movement_speed: float = 4.0
onready var navigation_agent = get_node("NavigationAgent")
onready var Player = get_node("../Player")
func _ready() -> void:
navigation_agent.get_target_location(Player.position)
func _process(delta):
move_toward(navigation_agent.get_target_location().x, 0, navigation_agent.get_target_location().z)
look_at(navigation_agent.get_target_location(), Vector3.UP)
The Player and Zombie are both parented to the world. For some reason, the Player.position throws an invalid index error, even though I dragged/dropped the Player node right into the code when I was making this. Please help me figure out why I can’t get this to run?
Thank you.
PS: I know Navmeshes and Navigation agents are deprecated. I am simply trying to grasp the basics of navigation.
This is all of the code needed. Don’t worry about the whole “in_shape” thing, it’s not relevant for the problem. I hope this helps you, if you have a question, please ask.
Have a great day
Apologies, I left my old engine and never fully understood navigation there, either. I honestly have no idea what I’m doing, and the tuts I’m finding are not for my Godot version.
That demo uses a navigation server, though, yes? Not the system I’m using rn just to practice. I could use the nav server, but I don’t understand either method.