コード例 #1
0
        public override void Execute(object o)
        {
            if (cameraTransform.value == null)
            {
                return;
            }

            if (o is ActionHook)
            {
                ActionHook a = (ActionHook)o;
                Transform  t = a.mTransform;

                float h = horizontal.value;
                float v = vertical.value;

                Vector3 rotateDir = cameraTransform.value.forward * v;
                rotateDir += t.right * h;


                if (rotateDir == Vector3.zero)
                {
                    rotateDir = t.forward;
                }

                Quaternion targetRot = Quaternion.LookRotation(rotateDir);
                Quaternion rotation  = Quaternion.Slerp(t.rotation, targetRot, Time.deltaTime * 8f);
                t.rotation = rotation;
            }
        }
コード例 #2
0
 public override void Execute(object o)
 {
     if (o is ActionHook)
     {
         ActionHook a = (ActionHook)o;
         targetTransform.value = a.mTransform;
         a.currentState        = null;
     }
 }
コード例 #3
0
        public override void Execute(object o)
        {
            if (o is ActionHook)
            {
                ActionHook a = (ActionHook)o;
                Transform  t = a.mTransform;

                float h          = horizontal.value;
                float v          = vertical.value;
                float moveAmount = Mathf.Clamp01(Mathf.Abs(h) + Mathf.Abs(v));

                Vector3 moveDir = t.forward * moveAmount;

                t.position += moveDir * .04f;
            }
        }