0 votes

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():
tree(), "idleframe")
var tree = get
if tree.has.group("Labe"):
levelNavegation = tree.getnodesingroup("LevelNavigation")[0]
if tree.has
player = tree.getnodesin_group("player")[0]

func physicsprocess(delta):
line2d.globalposition = Vector2.ZERO
if player and levelNavegation:

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

    if global_position == path[0]:

func generatepath():
if levelNavegation != null and player != null:
path = levelNavegation.get
simplepath(globalposition, player.global_position, false)
line2d.points = path

func move():
velocity = moveandslide(velocity)

Godot version Godot_v3.4-stable_mono_win64
in Engine by (12 points)

1 Answer

0 votes

For the mentioned error, this:

if tree.has.group("Labe"):

... should be this:

if tree.has_group("Labe"):

Notice I changed a . to an _.

by (12,460 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.