Blipples
May 9th, 2024
1
0
Never
This is comment for paste PlayerInteractCode
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private void OnTriggerEnter2D(Collider2D collision)
  2. {
  3. // Get x/y values for movement if the character isn't colliding with anything
  4. if (!base.IsOwner)
  5. {
  6. return;
  7. }
  8.  
  9. // Check if the collided object is interactable
  10. IInteractable interactableObjectColliding = collision.GetComponent<IInteractable>();
  11.  
  12. if (interactableObjectColliding != null)
  13. {
  14. interactableObjectName = collision.gameObject.name;
  15. interactableObject = collision.GetComponent<IInteractable>();
  16. LogManager.Instance.Log($"{gameObject.name} is near {interactableObjectName}");
  17. }
  18. }
  19.  
  20. private void OnTriggerExit2D(Collider2D collision)
  21. {
  22. // Get x/y values for movement if the character isn't colliding with anything
  23. if (!base.IsOwner)
  24. {
  25. return;
  26. }
  27.  
  28. // Check if the collided object is interactable
  29. IInteractable interactableObjectColliding = collision.GetComponent<IInteractable>();
  30.  
  31. if (interactableObjectColliding != null)
  32. {
  33. LogManager.Instance.Log($"{gameObject.name} is no longer near {interactableObjectName}");
  34. interactableObjectName = null;
  35. interactableObject = null;
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment