I'm trying to make the enemy follow the player following a tutorial, but I get an error when starting { invalid get index 'has' (on base: 'scene tree') }.
This is my code
extends KinematicBody2D
export(int) var SPEED: int = 150
var velocity: Vector2 = Vector2.ZERO
var path: Array = []
var levelNavegation: Navigation2D = null
var player = null
onready var line2d = $Line2D
func ready():
yield(gettree(), "idleframe")
var tree = gettree()
if tree.has.group("Labe"):
levelNavegation = tree.getnodesingroup("LevelNavigation")[0]
if tree.hasgroup("Player"):
player = tree.getnodesin_group("player")[0]
func physicsprocess(delta):
line2d.globalposition = Vector2.ZERO
if player and levelNavegation:
generatepath()
navigate()
move()
func navigate():
if path.size() > 0:
velocity = globalposition.directionto(path[1]) * SPEED
if global_position == path[0]:
path.pop_front()
func generatepath():
if levelNavegation != null and player != null:
path = levelNavegation.getsimplepath(globalposition, player.global_position, false)
line2d.points = path
func move():
velocity = moveandslide(velocity)