Exemplo n.º 1
0
 protected override void OnLateUpdate()
 {
     base.OnUpdate();
     if (checkGrabTarget)
     {
         // See OnFistStart()
         checkGrabTarget = false;
         testGrabTarget();
     }
     // After our OnUpdate, someone resets the position in their OnUpdate.
     // Using OnLateUpdate works, but only while grabbing.
     // After assigning HAnimation to the girl, it works in OnUpdate without any foreign resets.
     if (grabbing && currentEffector != null)
     {
         var effector = currentEffector.Effector;
         effector.positionWeight = 1f; // XXX weight 1 too strong? deformation possible. experiment with RotationLimit.
         var handPos = IKHelper.GetHandPosition(hand);
         var handRot = IKHelper.GetHandRotation(hand);
         effector.position = handPos;
         var newRot = Quaternion.Inverse(handRot) * startingRotation;
         effector.rotation = newRot;
     }
     else if (fisting && Time.time - fistStart > FIST_START_THRESHOLD)
     {
         Logger.Info("now grabbing {0}", currentEffector == null ? "nothing" : "something");
         grabbing = true;
     }
 }
Exemplo n.º 2
0
        protected void testGrabTarget()
        {
            fistStart = Time.time;
            var closest = FindIkEffectorAndActorInRange();

            if (closest != null)
            {
                fisting          = true;
                currentEffector  = closest;
                startingRotation = IKHelper.GetHandRotation(hand);
            }
            else
            {
                Logger.Info("No effector in range");
            }
        }