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;
}
}
}
↧