#Death animation not playing when player collides with enemu
1 messages · Page 1 of 1 (latest)
what's the code you have?
func die() -> void:
animated_sprite_2d.animation = "dying
alive = false
[]cb
Use codeblocks to send code in a message!
To make a codeblock, surround your code with ``` (3 backticks. Click here to see where the key is)
To use syntax highlighting, add the file extension of the language you wish to highlight (cs for C#, cpp for C++)
For example:
```cs
Console.WriteLine("Hello World");
```
Produces:
Console.WriteLine("Hello World");
To send lengthy code, paste it into https://paste.myst.rs/ and send the link of the paste into chat.
but how are you calling it?
calling it?
player scene?
"player_died"
is that a signal you've defined?
that's not connected to anything
the body.die()?
no i mean the _on_player_died function doesn't have a signal connected to it
if it did, it'd have a little green arrow icon to the left of the line number
green arrow icon?
you don't have that, so it's not connected to a signal
how do i connect it?
select your node (probably an area2d?), go into the 'Node' tab and connect the signal you want to the _on_player_died function
what's the script with _on_player_died on?
alright, then go to the snail scene and connect the signal to the function (in the 'node' tab)
its connected, i think?
on the signals tab it does but i dont see it on the script itself
did you connect it to the right method?
oh now it does-
should work now then
what target?
that's saying that this method (_on_body_entered, which isn't the _on_player_died method) has a body_entered signal connected to it from the source Snail area2d to a target Snail area2d (they're the same node)
you connected it to a different method it looks like
where is it meant to be??
what function do you want to get called when a body enters the area?
on_player_died
then connect it to that function
there's a little pencil icon you can press to select a method when connecting it iirc
where do i find that?
when you're connecting the signal
idk???
on_player_died?
yeah
this then popped up
what are you doing in the _on_body_entered bit?
why are you connecting the player_died signal?
huh?
oh
which then calls die on the body
ah huh?
in the pick menu
though it might not show it if it doesn't have a body param? not sure
but you'll have to add it anyways
which is the last one?
well yeah
yeah now just call the die method on body if it's the player
and you don't even need the _on_body_entered function
what do i put under "func _on_player_died(body: Node2D) -> void:"?
well whatever was there at the start
do i just get rid of the "func _on_body_entered(body: Node2D) -> void:" above that??
yeah
now what??
now run it
i did
so what happened?
nothings happening
did you put anything on _on_player_died
how do i check that?
by looking at it???
what's in the _on_player_died function
that's not what i asked
look at the function...
no clue