Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | koosha |
I am trying to get a function from my main play to an enemy. This is the character code
func ouch(var posx):
set_modulate(Color(1,0.3,0.3,0.3))
velocity.y = JUMPFORCE * 0.7
if position.x < posx:
velocity.x = -800
elif position.x > posx:
velocity.x = 800
Input.action_release("Left")
Input.action_release("Right")
Here is my enemy code for this function
func _on_Topdetector_body_entered(body):
$AnimatedSprite.play(“Dead”)
speed = 0
set_collision_layer_bit(4,false)
set_collision_mask_bit(0,false)
$Topdetector.set_collision_layer_bit(4,false)
$Topdetector.set_collision_mask_bit(0,false)
$SideChecker.set_collision_layer_bit(4,false)
$SideChecker.set_collision_mask_bit(0,false)
$Timer.start()
body.bounce()
$Kill.play()
func _on_SideChecker_body_entered(body):
body.ouch(position.x)
func _on_Timer_timeout():
queue_free()