Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Zylo_X |
Hello There
i have an Area 2D character he must avoid viruses or he will die
and he has to take the pills in order to get bonus ( both rigid bodies 2D )
.
how i can hide the pills after the player collide with them !!! (the collides happen and the prove is my bonus increases in HUD)
why i can’t call the function which suppose to hide the Pills from the pill script !!!
This is my First Game In GODOT
below pill script # which i want to hide when the player collide with them
extends RigidBody2D
export(int) var MAX_SPEED
export(int) var MIN_SPEED
var Pill_types=[‘Green’,‘Red’,‘Blue’,‘Yellow’]
func _ready():
$AnimatedSprite.animation=Pill_types[randi()% Pill_types.size()]
add_to_group(“Collectible”)
func Pill_flee():
queue_free()
func die ():
hide()
queue_free()
here is the detect function in player’s script
i put this line before fun _ready ()
var Pill= preload(“res://scene/Pill.tscn”)
func Body_Detect(body):
if body.is_in_group("Enemies"):
hide()
emit_signal("hit")
call_deferred("set_monitoring",false)
if body.is_in_group("Collectible"):
var pill_child= Pill.instance()
add_child(pill_child)
emit_signal("eat") # call score update in main
Pill_child.die() # call die() func in Pill