Guest User

Untitled

a guest
Nov 5th, 2023
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | Source Code | 0 0
  1.         void Update()
  2.         {
  3.             // TOP LEFT
  4.             Collider[] topLeftColliders = Physics.OverlapSphere(topLeft.position, radius);
  5.  
  6.             // Loop through the colliders to perform actions with them
  7.             foreach (Collider collider in topLeftColliders)
  8.             {
  9.                 // Do something with the collider (e.g., access its GameObject, apply forces, etc.)
  10.                 GameObject otherObject = collider.gameObject;
  11.                 GameObject parentOtherObject = otherObject.transform.root.gameObject;
  12.  
  13.                 Debug.Log("carrot1");
  14.                 if (otherObject.tag == "TopRightSnapPoint")
  15.                 {
  16.                     Debug.Log("hello1");
  17.                     renderer = GetComponent<MeshRenderer>();
  18.                     size = renderer.bounds.size;
  19.                     size = new Vector3(size.x, 0, 0);
  20.                     Debug.Log(size);
  21.                     Debug.Log(topLeft);
  22.  
  23.                     GameObject parentTopLeft = topLeft.transform.root.gameObject;
  24.                     parentTopLeft.transform.position = parentOtherObject.transform.position - size;
  25.                     parentTopLeft.transform.rotation = parentOtherObject.transform.rotation;
  26.                 }
  27.  
  28.             }
Advertisement
Add Comment
Please, Sign In to add comment