Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | worstprogrammer | |
Old Version | Published before Godot 3 was released. |
So im making a simple 2D game and im having some problems with collision.
I want my character to basically die,trigger a Particle2D node and restart the scene when he collides with an object.When he collides the game crashes and i get the error:
Invalid call. Nonexistent function ‘defeat’ in base ‘Area2D (player.gd)’
The obstacle node is connected to on_obstacles_
This is the code on the player script :
var defeated=false
func _defeat():
if(defeated):
return
get_node("player_sprite").hide()
get_node("explosion").set_emitting(true)
defeated(true)
And this is the code in the obstacle script :
func _on_obstacles_area_enter( area ):
if(area.get_name()=="player"):
area.defeat()
Idk why the script doesnt recognize the defeat function on the player script.
Thanks,
atze | 2016-06-27 05:35