Hello, I'm currently following an enemy AI tutorial at [
] and I can't get the enemy to follow my character. The problem occurs at roughly 13:44 time in the video.
I'm altering the tutorial with the 3D mannequin tutorial I have already completed from the GD quest website, but I don't know if that matters or not. So instead of using the first person character controller that is demonstrated in the video, I am using the 3d mannequin.
My current code for the Enemy.gd script is as below: (excluding the lines below and beneath it)
extends KinematicBody
var target
func body_entered(body):
target = body
func _physics_process(delta):
if target:
look_at(target.global_transform.origin, Vector3.UP)
func _on_Area_body_entered(body):
print(body.name + " entered")
set_color_red()
if body.is_in_group("Player"):
target = body
func _on_Area_body_exited(body):
print(body.name + " exited")
set_color_green()
if body.is_in_group("Player"):
target = null
func set_color_red():
$MeshInstance.get_surface_material(0).set_albedo(Color(1, 0, 0))
func set_color_green():
$MeshInstance.get_surface_material(0).set_albedo(Color(0, 1, 0))
I have been trying everything I can and don't know why this isn't working, as it works fine for the person in the video. Please help.