Advertisement
PetrifiedOnion

Godot Stuff

Jun 15th, 2024
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extends CharacterBody2D
  2.  
  3. # Get the gravity from the project settings to be synced with RigidBody nodes.
  4. var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
  5.  
  6.  
  7. func _physics_process(delta):
  8.     # Add the gravity.
  9.     if not is_on_floor():
  10.         velocity.y = gravity * delta
  11.  
  12.     move_and_collide(velocity * delta)
  13.  
  14.  
  15. func _on_area_2d_body_entered(body):
  16.     if body.name == "Ball":
  17.         print("hit")
  18.         queue_free()
  19.  
  20.  
  21. func _on_area_2d_body_exited(body):
  22.     if body.name == "Ball":
  23.         print("hit")
  24.         queue_free()
  25.  
  26.  
  27. func _on_area_2d_area_entered(area):
  28.     if area.name == "Impact":
  29.         print("hit")
  30.         queue_free()
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement