public void AddForceWithMove()
        {
            Vector3  forceVector;
            Property ep = property;

            forceVector = Vector3.Scale(ep.moveToVector, Controller.stick[EPosType.Move]);
            if (Button.Judge(property.jumpButton, property.jumpMode))
            {
                if (property.jumpVector == Vector3.zero)
                {
                    property.jumpVector = Vector3.up * 500;
                }
                forceVector = property.jumpVector + forceVector;
            }
            forceVector = Vector3.Scale(ep.forceVector, forceVector);
            if (rigid != null)
            {
                forceVector = VecComp.LimitForce(forceVector, rigid.velocity, ep.maxVelocity, ep.biasMaxVelocity);
                rigid.AddForce(forceVector);
            }
            else if (rigid2 != null)
            {
                forceVector = VecComp.LimitForce(forceVector, rigid2.velocity, ep.maxVelocity, ep.biasMaxVelocity);
                rigid2.AddForce(forceVector);
            }
        }
        private void PositionUpdate()
        {
            if (followObject != null)
            {
                transform.position = FollowObject.transform.position + RelativeOffset;
            }
            BaseRotation = VecComp.ExtractionAxis(transform.rotation, BaseAxis);

            if (Camera.main != null)
            {
                CinemachineBrain cmBrain = Camera.main.GetComponent <CinemachineBrain>();
                if (CmBrain != cmBrain)
                {
                    CmBrain = cmBrain;
                }
            }
            if (CmBrain != null)
            {
                if (CmBrain.ActiveVirtualCamera != null)
                {
                    string cmName = CmBrain.ActiveVirtualCamera.Name;
                    if (cmName != CmName)
                    {
                        CmName = cmName;
                        var findCamera = GameObject.Find(CmName);
                        if (findCamera != null)
                        {
                            CmCamera = findCamera.GetComponent <CinemachineVirtualCamera>();
                        }
                    }
                }
            }
            else
            {
                CmCamera = null;
            }
            if (CmCamera != null)
            {
                // コントローラのアクティブ化、基本はFollowを参照、LookAtはFollowがNullのときだけ
                if (SwitchControllFromCameara && (Controller != null))
                {
                    if (CmCamera.Follow != null)
                    {
                        Controller.Active = (CmCamera.Follow.gameObject == gameObject);
                    }
                    else
                    {
                        if (CmCamera.Follow != null)
                        {
                            Controller.Active = (CmCamera.LookAt.gameObject == gameObject);
                        }
                        else
                        {
                            Controller.Active = false;
                        }
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// 対象ベクトルに向かっての配置
        /// </summary>
        public void SeeFollow(Vector3 euler, Vector3 target, float timer = DEFAULT_TIMER)
        {
            if (toEuler != euler || DoUpdate)
            {
                fromEuler = VecComp.AbsCompFloor(followerObject.transform.eulerAngles);
                toEuler   = VecComp.EulerShortest(fromEuler, euler);
                if (timer <= 0f)
                {
                    if (AngularVelocityOfDegree != 0f)
                    {
                        timer = Vector3.Distance(fromEuler, toEuler) / AngularVelocityOfDegree;
                    }
                    else
                    {
                        timer = Time.deltaTime;
                    }
                }
                countTimer = Time.deltaTime;
                maxTimer   = timer;
                if (maxTimer <= 0f)
                {
                    maxTimer = SetOtherMaxTimer;
                }
            }
            if (maxTimer > 0f)
            {
                float ratio = countTimer / maxTimer;
                if (ratio >= 1f)
                {
                    ratio    = 1f;
                    maxTimer = 0f;
                }

                Vector3 nextEuler = Vector3.Lerp(fromEuler, toEuler, ratio);
                target += RelativeOffset;
                Transform tf = followerObject.transform;
                if (mode2D)
                {
                    nextEuler.x = 0; nextEuler.y = 0;
                }
                tf.eulerAngles = nextEuler;
                Vector3 toVector = target + -tf.forward * Distance;
                if (DistanceToSize && followerCamera.orthographic)
                {
                    followerCamera.orthographicSize = Distance;
                }
                tf.position = toVector;
            }
            DoUpdate = false;
        }
示例#4
0
 new void Update()
 {
     base.Update();
     if (maxTimer > 0f)
     {
         countTimer += Time.deltaTime;
     }
     SubUpdate();
     if (followVector != FollowObject.transform.position)
     {
         DoUpdate = true;
     }
     followVector = FollowObject.transform.position;
     SeeLimit();
     SeeFollow();
     EulerAngle = VecComp.AbsDeg(EulerAngle);
 }
示例#5
0
 /// <summary>
 /// 視点の範囲制限、0~360で正規化
 /// </summary>
 float SeeLimit(float value, ref float min, ref float max)
 {
     if ((max == 0f) && (min == 0f))
     {
         return(value);
     }
     if (max < 0)
     {
         max = VecComp.AbsDeg(max);
     }
     if (min < 0)
     {
         min = VecComp.AbsDeg(min);
     }
     if (min > max)
     {
         float mid = (min + max) / 2;
         if (max < value && value < min)
         {
             if (mid >= value)
             {
                 value = max;
             }
             else
             {
                 value = min;
             }
         }
     }
     else
     {
         if (max < value)
         {
             value = max;
         }
         else if (min > value)
         {
             value = min;
         }
     }
     return(value);
 }
 /// <summary>
 /// サブモジュール、継承してなんやかんやするならここ
 /// </summary>
 protected void SubUpdate()
 {
     if (PermissionController)
     {
         // クォータニオンで角度回転
         Vector3 stick_move = Stick[EPosType.Rot];
         transform.rotation =
             Quaternion.Lerp(transform.rotation,
                             Quaternion.AngleAxis(stick_move.x, new Vector3(0, 1, 0))
                             * Quaternion.AngleAxis(stick_move.y, transform.right)
                             * transform.rotation, Time.deltaTime * Smooth * 8);
         // 上下90度をキープする、yとzの中間を取る
         transform.rotation = VecComp.RotLimit(transform.rotation,
                                               Vector3.right, MinBaseAngle, MaxBaseAngle);
         // Yボタンで視点リセット
         RotForward(Button.Judge(ViewForwardButton, resetRotButtonMode));
         // カムバックボタン
         if (Button.Judge(RespawnButton, EButtonMode.Down))
         {
             FollowObject.transform.position = RespawnPosition;
         }
     }
 }