#Some enemies with the same script crashes my game
12 messages · Page 1 of 1 (latest)
ive seen references bhefore that "get_parent()" tends to cause issues like this. you could probab fix this by instead of useing get parent. make it set a "hurt" variable to true. then in the code of said parent, grab that variable and if true play hurt aniamtion. then set hurt to false again
the reason the get parent causes issues is when you instantiate that scene the parent heirchy isnt the same.
hmmmmmm
Like create a var base_patrol_hurt = false / in the EnemyBase and when
if base_patrol_hurt:
animated.2d_sprite.play("hurt")
?
I'll try
the code your replacing is in this highlighted line in this photo. so i think it has to be within that script the new variable.
this is essential what i was trying to explain to do. not knowing what the script hitbox.gd is tied to i tried to explain it the best i can
var gotHurt = false
func _on_body_entered(body):
if body.name =="player":
body.velocity.y = body.JUMP_FORCE / 2
gotHurt = true
inside that parent "get_parent()"
if $NAMEOFCHILD.gotHurt = true:
animated_sprite_2d.play("hurt")
I'll cry
but, I'll still trying, tks!!!