Advertisement
Guest User

Untitled

a guest
Feb 1st, 2025
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. extends Area2D
  2.  
  3. var player_inside: bool = false
  4. var body2: CharacterBody2D
  5.  
  6. func _process(delta):
  7. if player_inside == true && body2 != null:
  8. continous_detection(body2)
  9.  
  10. func continous_detection(body2):
  11. if player_inside == true:
  12. for i in get_children():
  13. var a = Transform2D(0, i.global_position)
  14. var b = Transform2D(0, body2.col.global_position)
  15. var is_colliding = i.shape.collide(a,body2.col.shape,b)
  16. if is_colliding == true:
  17. print(i.shape)
  18.  
  19. func _on_body_entered(body):
  20. body2 = body
  21. player_inside = true
  22.  
  23. func _on_body_exited(body):
  24. body2 = null
  25. player_inside = false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement