For a side scroller game i need variuous scene ( main , player , weapon, enemy ).
In the script of the main one, I instance them with "add_child" and they spawn correctly on the screen with their variables.
Now i want to add collision to player, bullet and enemy that are all RigidBody2D with their CollisionShape2D.
This is the code for the Enemy
extends RigidBody2D
var life = 250
func _ready():
get_node("Timer").start()
pass
func _on_weapon_body_entered(body):
if body.is_in_group("weapon"):
life=life-body.damage
else:
life=life+1
pass
func _on_Timer_timeout():
get_node("Label").text=String(life)
get_node("Timer").start()
pass
In the weapon scene there is a group called weapon
What is the problem?