예제 #1
0
 public Vector3 GetVelocity(Rigidbody rigidbody, Vector3 refPoint) // from Ferram
 {
     Vector3 newVelocity = Vector3.zero;
     //newVelocity = commonRigidBody.velocity + Krakensbane.GetFrameVelocity() + Vector3.Cross(commonRigidBody.angularVelocity, liftTransform.position - commonRigidBody.position);
     newVelocity += rigidbody.GetPointVelocity(refPoint);
     newVelocity += Krakensbane.GetFrameVelocityV3f() - Krakensbane.GetLastCorrection() * TimeWarp.fixedDeltaTime;
     return newVelocity;
 }
 static public int GetPointVelocity(IntPtr l)
 {
     try {
         UnityEngine.Rigidbody self = (UnityEngine.Rigidbody)checkSelf(l);
         UnityEngine.Vector3   a1;
         checkType(l, 2, out a1);
         var ret = self.GetPointVelocity(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
		public override void OnEnter ()
		{
			rigidbody = ownerDefault.GetComponent<UnityEngine.Rigidbody> ();
			Vector3 velocity = Vector3.zero;
			switch (space) {
			case Space.Self:
				velocity=rigidbody.GetRelativePointVelocity (owner.GetValue (position));
				break;
			case Space.World:
				velocity=rigidbody.GetPointVelocity (owner.GetValue (position));
				break;
			}
			owner.SetVector3 (store,velocity);
			Finish ();
		}
예제 #4
0
 static int GetPointVelocity(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Rigidbody obj  = (UnityEngine.Rigidbody)ToLua.CheckObject(L, 1, typeof(UnityEngine.Rigidbody));
         UnityEngine.Vector3   arg0 = ToLua.ToVector3(L, 2);
         UnityEngine.Vector3   o    = obj.GetPointVelocity(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
        public override void OnEnter()
        {
            rigidbody = ownerDefault.GetComponent <UnityEngine.Rigidbody> ();
            Vector3 velocity = Vector3.zero;

            switch (space)
            {
            case Space.Self:
                velocity = rigidbody.GetRelativePointVelocity(owner.GetValue(position));
                break;

            case Space.World:
                velocity = rigidbody.GetPointVelocity(owner.GetValue(position));
                break;
            }
            owner.SetVector3(store, velocity);
            Finish();
        }
예제 #6
0
 public Vector3 GetVelocity(Rigidbody rigidbody, Vector3 refPoint) // from Ferram
 {
     Vector3 newVelocity = Vector3.zero;
     try
     {
         newVelocity += rigidbody.GetPointVelocity(refPoint);
         newVelocity += Krakensbane.GetFrameVelocityV3f() - Krakensbane.GetLastCorrection() * TimeWarp.fixedDeltaTime;
     }
     catch (Exception e)
     {
         if (debugMode)
             Debug.Log("FSengineBladed GetVelocity Exception " + e.GetType().ToString());
     }
     return newVelocity;
 }
예제 #7
0
 public Vector3 GetVelocity(Rigidbody rigidbody, Vector3 refPoint) // from Ferram
 {
     Vector3 newVelocity = Vector3.zero;
     newVelocity += rigidbody.GetPointVelocity(refPoint);
     newVelocity += Krakensbane.GetFrameVelocityV3f() - Krakensbane.GetLastCorrection() * TimeWarp.fixedDeltaTime;
     return newVelocity;
 }
        public void FixedUpdate()
        {
            if (LeadTime == 0)
            {
                // ****** JUST PULL WITH TWO STRINGS TO FACE DIRECTION *****
                //
                if (FacingDirection != Vector3.zero)
                {
                    // *********************  FACE CHEST TOWARDS THE INPUT DIRECTION *******
                    _rigidbody.AddForceAtPosition(FacingForce * FacingDirection * Time.deltaTime, _rigidbody.transform.TransformDirection(BodyForward), ForceMode.Impulse);
                    _rigidbody.AddForceAtPosition(-FacingForce * FacingDirection * Time.deltaTime, _rigidbody.transform.TransformDirection(-BodyForward), ForceMode.Impulse);
                }
            }
            else
            {
                // ******** TRY PULL TOWARDS DIRECTION FACTORING IN VELOCITY (ie. decelerate towards the target) ***********
                Vector3 targetPoint  = transform.position + FacingDirection * BodyForward.magnitude;
                Vector3 currentPoint = transform.TransformPoint(BodyForward);
                Vector3 reversePoint = transform.TransformPoint(-BodyForward);
                Vector3 velocity     = _rigidbody.GetPointVelocity(currentPoint);
                Vector3 diff         = targetPoint - (currentPoint + velocity * LeadTime);

                _rigidbody.AddForceAtPosition(FacingForce * diff * Time.deltaTime, currentPoint, ForceMode.Impulse);
                _rigidbody.AddForceAtPosition(-FacingForce * diff * Time.deltaTime, reversePoint, ForceMode.Impulse);
            }
        }