Hello. I've been following the rogue-like tutorial found here and am currently on the fourth installment in that series implementing player movement in response to input.
I'm getting an "invalid set index" error when attempting to set a property from within one of my scripts. I'm having trouble determining whether the problem is that I'm retrieving a the node on which I wish to set the property incorrectly or it is the correct node but it isn't structured properly.
I'm hoping a fresh set of eyes can will be able to see what I'm doing wrong. I'm majestically inexperienced with Godot/GDScript so it may be something really simple.
The error is at the bottom of the IdlePlayer.gd input() function on the line:
state.delta_xy = delta_xy
Here are the relevant code files. I hope it's not too much to paste in but I figured more was better than less. Please let me know what other information I can provide.
IdlePlayer.gd
extends "Base.gd"
func enter(entity):
entity.set_fixed_process(false)
entity.set_process_input(true)
func input(entity, event):
var delta_xy
var isMoving = false
if (event.is_action_pressed("ui_right")):
delta_xy = entity.UNIT_RIGHT
isMoving = true
elif (event.is_action_pressed("ui_down")):
delta_xy = entity.UNIT_DOWN
isMoving = true
elif (event.is_action_pressed("ui_left")):
delta_xy = entity.UNIT_LEFT
isMoving = true
elif (event.is_action_pressed("ui_up")):
delta_xy = entity.UNIT_UP
isMoving = true
if isMoving:
var state = self.parent.get_node("Moving")
state.delta_xy = delta_xy
entity.transition_to(state)
Moving.gd
extends "Base.gd"
export var duration = 0.25
var _time_elapsed = 0
var _pos_start
var delta_xy
****snip****
Base.gd
extends Node
onready var parent = self.get_node("..")
func enter(entity):
pass
func input(entity, event):
pass
func update(entity, delta_time):
pass