I'm currently following this tutorial https://www.youtube.com/watch?v=fp_XugQvOKU&t=578s and change it a little bit (to fit with my project) and get this error:
Invalid get index 'texture' (on base: 'Nil').
the problem maybe because of my Sprite is null, but I don't know how to fix it, here is my code:
var sprite
var ghost_scene = preload("res://ghosteffect.tscn")
func _process(delta):
match state:
ROLL:
roll_state(delta, sprite)
func roll_state(delta, sprite):
self.sprite = sprite
velocity = velocity.move_toward(roll_vector * ROLL_SPEED, ACCELERATION * delta)
animationState.travel("Roll")
move()
instance_ghost()
func instance_ghost():
var ghost: Sprite = ghost_scene.instance()
get_parent().get_parent().add_child(ghost)
ghost.global_position = global_position
ghost.texture = sprite.texture
ghost.vframes = sprite.vframes
ghost.hframes = sprite.hframes
ghost.frame = sprite.frame
ghost.flip_h = sprite.flip_h
I have omitted some codes which aren't related to the sprite node, so please ask if you guys need more information (million thanks for the help!)