Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- seperateRooms()
- {
- // this adds the temporary rigidbody
- foreach (GameObject room in rooms)
- {
- room.AddComponent<Rigidbody>();
- room.GetComponent<Rigidbody>().isKinematic = true;
- room.GetComponent<Rigidbody>().useGravity = false;
- }
- for(int i = rooms.Count-1; i > 0; i--)
- {
- GameObject room = (GameObject)rooms[i];
- Rigidbody rb = room.GetComponent<Rigidbody>();
- rb.isKinematic = false;
- rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionY;
- while (!(rb.IsSleeping()))
- {
- rb.MovePosition(room.transform.position + room.transform.forward * Time.deltaTime);
- }
- rb.isKinematic = true;
- }
- foreach (GameObject room in rooms)
- {
- Destroy(room.GetComponent<Rigidbody>());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement