Advertisement
fosterboy123

Temp stop rigidbody

May 27th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class TemporarilyStopRigidbody : MonoBehaviour
  5. {
  6.     public Rigidbody Rigidbody;
  7.  
  8.     Vector3 m_LastVelocity;
  9.     Vector3 m_LastAngularVelocity;
  10.  
  11.     void Update()
  12.     {
  13.         if (Input.GetButtonDown("Fire2"))
  14.         {
  15.             m_LastVelocity = Rigidbody.velocity;
  16.             m_LastAngularVelocity = Rigidbody.angularVelocity;
  17.             Rigidbody.isKinematic = true;
  18.         }
  19.         else if (Input.GetButtonUp("Fire2"))
  20.         {
  21.             Rigidbody.isKinematic = false;
  22.             Rigidbody.velocity = m_LastVelocity;
  23.             Rigidbody.angularVelocity = m_LastAngularVelocity;
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement