please help me

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Manuel Paulucci

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(get_tree(), “idle_frame”)
var tree = get_tree()
levelNavegation = tree.get_nodes_in_group(“LevelNavigation”)[0]
if tree.has_group(“Player”):
player = tree.get_nodes_in_group(“player”)[0]

func _physics_process(delta):
line2d.global_position = Vector2.ZERO
if player and levelNavegation:

func navigate():
if path.size() > 0:
velocity = global_position.direction_to(path[1]) * SPEED

	if global_position == path[0]:

func generate_path():
if levelNavegation != null and player != null:
path = levelNavegation.get_simple_path(global_position, player.global_position, false)
line2d.points = path

func move():
velocity = move_and_slide(velocity)

:bust_in_silhouette: Reply From: jgodfrey

For the mentioned error, this:


… should be this:

if tree.has_group("Labe"):

Notice I changed a . to an _.