This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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:
        if bigchunk.x <= player.x:
 for left in bigchunkleft.get_children():
    if left.is_colliding():
        if bigchunk.x >= player.x:
        if bigchunk.x <= player.x:

func on_animation_finished():

pls help

Godot version godot 3.3
in Engine by (58 points)

1 Answer

0 votes

You are playing the same animation, "deadright", regardless of what if conditional is true. This is a copy/paste error.

by (3,906 points)

My god, I forgot to check if someone gonna answer this, by the way, I have already fixed my problem with this:

func _on_start_no_health():
is_dead = true
_player = null
$shadow.visible = false
if player.position.y >= position.y:"Dead Down")
if player.position.y <= position.y:"Dead Up")
for L in $bigchunkbothsides.get_children():
    if L.is_colliding():
        if player.position.x <= position.x:
  "Dead Left")
        if player.position.x >= position.x:
  "Dead Right")

But still thanks for your help, seeing someone answer my silly problem really make my day :v

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 Frequently asked questions and 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 [email protected] with your username.