Exemple #1
0
 void SetMoviment(float Direction, float Sentido, bool SetAnim, int LegState, int ArmSate)
 {
     Dir = Mathf.LerpAngle(Direction, Sentido, Translação * Time.deltaTime);
     if (SetAnim)
     {
         AnimPerna.SetInteger("Andar", LegState);
         AnimBraço.SetInteger("BraçoAndar", ArmSate);
     }
 }
Exemple #2
0
    void SetAllSprings()
    {
        if (AllHingeJoints.Length > 0)
        {
            if (AllHingeJoints[0].useSpring != UseSpring) // com isto, estas coisas só aconteceram em 1 frame, e não a todo momento
            {
                for (int x = 0; x < AllHingeJoints.Length; x++)
                {
                    AllHingeJoints[x].useSpring = UseSpring;
                    if (UseSpring == true)
                    {
                        JointSpring Sp = AllHingeJoints[x].spring;
                        Sp.spring = ForçaInicial;
                        AllHingeJoints[x].spring = Sp;
                    }
                }


                TimeReborn = 0;
                AnimBraço.SetInteger("BraçoAndar", -10);
                AnimPerna.SetInteger("Andar", -10);
                AnimBraço.StopPlayback();
                AnimPerna.StopPlayback();
            }
            if (TimeReborn <= TempoLevantar)
            {
                TimeReborn += 1 * Time.deltaTime;
                if (UseSpring == true)
                {
                    GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation;
                    transform.rotation = Quaternion.Lerp(transform.rotation, RotAnt, 2f * Time.deltaTime);
                    AnimBraço.SetInteger("BraçoAndar", -10);
                    AnimPerna.SetInteger("Andar", -10);
                    AnimBraço.Play(1);
                    AnimBraço.Play(1);
                }
                else
                {
                    RotAnt     = transform.rotation;
                    TimeReborn = 500;
                    GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None;
                    for (int x = 0; x < ColisoresIK.Length; x++)
                    {
                        ColisoresIK[x].enabled = UseSpring;
                    }
                }
            }
            else
            {
                if (TimeReborn != 500)
                {
                    var AnguloY = Mathf.LerpAngle(transform.eulerAngles.y, CameraRot.eulerAngles.y, 2.5f * Time.deltaTime);
                    transform.eulerAngles = new Vector3(0, AnguloY, 0);
                    for (int x = 0; x < ColisoresIK.Length; x++)
                    {
                        ColisoresIK[x].enabled = UseSpring;
                    }
                    for (int x = 0; x < AllHingeJoints.Length; x++)
                    {
                        JointSpring Sp = AllHingeJoints[x].spring;
                        Sp.spring = PreviousString[x];     // o spring original dos ossos
                        AllHingeJoints[x].spring = Sp;
                    }
                    TimeReborn = 500;
                }
            }
        }
    }