Advertisement
otorp2

kinematic on_body_enter

Jul 8th, 2016
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. Hey, guys, I really don't get how to use a body_enter function, please explain.
  2. I got two nodes Player and Enemy and they both are KinematicBodies2D.
  3. Enemy node has got an Area2D node in it with script like this:
  4.  
  5. extends Area2D
  6.  
  7. func _ready():
  8. connect("body_enter", self, "_on_enemy_body_enter")
  9.  
  10.  
  11. func _on_enemy_body_enter(body):
  12. print("Collision")
  13. if (body.get_name == "Player"):
  14. print("Ouch!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement