Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | cookieoil |
I’m trying to make the enemy to play animation in specific directions, but the raycast not working
extends AnimatedSprite
onready var bigchunk = get_node("/root/world/YSort/BigChunk").global_position
onready var player = get_parent().get_node("/root/world/YSort/Player").global_position
onready var bigchunkright = preload("res://bigchunkrights.tscn").instance()
onready var bigchunkleft = preload("res://bigchunklefts.tscn").instance()
func _ready():
connect("animation_finished", self, "on_animation_finished")
func _process(delta):
for right in bigchunkright.get_children():
if right.is_colliding():
if bigchunk.x >= player.x:
play("deadright")
if bigchunk.x <= player.x:
play("deadright")
for left in bigchunkleft.get_children():
if left.is_colliding():
if bigchunk.x >= player.x:
play("deadright")
if bigchunk.x <= player.x:
play("deadright")
func on_animation_finished():
queue_free()
pls help