Quantcast
Viewing latest article 21
Browse Latest Browse All 102

How do I make and object's position and rotation independent again?

Just as the title says. How can I make the position of an object independent again after making it dependent earlier. This is what I have right now: if(ItemPickedUp == true){ // If you press the E key. if(Input.GetKeyDown("e")){ // The CarryableObject becomes a child of the Utility Props again. CarryableObject.transform.parent = UtilityProps.transform; // The drop position. CarryableObject.transform.position = new Vector3(Character.transform.position.x, Character.transform.position.y, Character.transform.position.z + OffsetDropPosition); // The rotation is no longer relative to the Character. CarryableObject.transform.rotation = Character.transform.rotation; // The gravity gets reenabled. CarryableObject.GetComponent().useGravity = true; // The child collider if-statements. if(Child1 != null){ Child1.GetComponent().enabled = true; } if(Child2 != null){ Child2.GetComponent().enabled = true; } if(Child3 != null){ Child3.GetComponent().enabled = true; } if(Child4 != null){ Child4.GetComponent().enabled = true; } } }

Viewing latest article 21
Browse Latest Browse All 102

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>