Пример #1
0
    void LateUpdate()
    {
        //*************************************************************************************************************************************************
        // Bone rotation
        if (!shared.IsActive)
        {
            return;
        }

        //Set const varialbes to shared script
        shared.crouch_max = 0.0f;
        shared.ang_t      = ANGT;
        shared.yaw_max    = 0.0f;
        shared.pitch_max  = 0.0f;

        //Save head position befor transformation
        shared.fixedHeadPos = Head.position;

        if (shared.lastHit != 0)        //Taking damage animation
        {
            shared.lastHit--;
            Head.GetChild(0).transform.rotation *= Quaternion.Euler(0, shared.lastHit, 0);
        }
        else if (reset)        //Reset
        {
            swimRoll  = Mathf.Lerp(swimRoll, 0.0f, 0.01f); anm.SetFloat("Turn", Mathf.Lerp(anm.GetFloat("Turn"), 0.0f, 0.01f));
            swimPitch = Mathf.Lerp(swimPitch, 0.0f, 0.01f); anm.SetFloat("Pitch", Mathf.Lerp(anm.GetFloat("Pitch"), 0.0f, 0.01f));
        }

        //Pitch/roll root
        Root.transform.RotateAround(transform.position, Vector3.up, reverse = Mathf.Lerp(reverse, invert?180f : 0.0f, 0.05f));
        Root.transform.rotation *= Quaternion.Euler(Mathf.Clamp(-swimPitch, -90, 90), Mathf.Clamp(swimRoll, -25, 25), 0);

        //Tantacles rotation
        if (!shared.IsAttacking && !reset)
        {
            if (Mathf.Abs(swimPitch - (anm.GetFloat("Pitch") * 90)) < 45)
            {
                tentaclesPitch = Mathf.Lerp(tentaclesPitch, 0.0f, 0.025f);
            }
            else
            {
                tentaclesPitch = Mathf.Lerp(tentaclesPitch, invert?-anm.GetFloat("Pitch") * 8 : anm.GetFloat("Pitch") * 8, 0.1f);
            }
            tentaclesAng = Mathf.Lerp(tentaclesAng, anm.GetFloat("Turn") * 8, 0.025f);
        }
        else
        {
            tentaclesPitch = Mathf.Lerp(tentaclesPitch, 0.0f, 0.1f);        tentaclesAng = Mathf.Lerp(tentaclesAng, 0.0f, 0.1f);
        }

        Body.transform.rotation      *= Quaternion.Euler(0, 0, tentaclesAng * 2);
        Tentacles.transform.rotation *= Quaternion.Euler(-tentaclesPitch, 0, tentaclesAng * 4);

        Right0.transform.rotation *= Quaternion.Euler(0, tentaclesPitch, tentaclesAng);
        Right1.transform.rotation *= Quaternion.Euler(0, tentaclesPitch, tentaclesAng);
        Right2.transform.rotation *= Quaternion.Euler(0, tentaclesPitch, tentaclesAng);
        Right3.transform.rotation *= Quaternion.Euler(0, tentaclesPitch, tentaclesAng);
        Right4.transform.rotation *= Quaternion.Euler(0, tentaclesPitch, tentaclesAng);
        Right5.transform.rotation *= Quaternion.Euler(0, tentaclesPitch, tentaclesAng);
        Right6.transform.rotation *= Quaternion.Euler(0, tentaclesPitch, tentaclesAng);
        Right7.transform.rotation *= Quaternion.Euler(0, tentaclesPitch, tentaclesAng);
        Right8.transform.rotation *= Quaternion.Euler(0, tentaclesPitch, tentaclesAng);

        Left0.transform.rotation *= Quaternion.Euler(-tentaclesPitch, 0, tentaclesAng);
        Left1.transform.rotation *= Quaternion.Euler(-tentaclesPitch, 0, tentaclesAng);
        Left2.transform.rotation *= Quaternion.Euler(-tentaclesPitch, 0, tentaclesAng);
        Left3.transform.rotation *= Quaternion.Euler(-tentaclesPitch, 0, tentaclesAng);
        Left4.transform.rotation *= Quaternion.Euler(-tentaclesPitch, 0, tentaclesAng);
        Left5.transform.rotation *= Quaternion.Euler(-tentaclesPitch, 0, tentaclesAng);
        Left6.transform.rotation *= Quaternion.Euler(-tentaclesPitch, 0, tentaclesAng);
        Left7.transform.rotation *= Quaternion.Euler(-tentaclesPitch, 0, tentaclesAng);
        Left8.transform.rotation *= Quaternion.Euler(-tentaclesPitch, 0, tentaclesAng);

        //Check for ground layer
        shared.GetGroundAlt(false, 0.0f);

        //*************************************************************************************************************************************************
        // CPU (require "JP script extension" asset)
        if (shared.AI && shared.Health != 0)
        {
            shared.AICore(1, 2, 3, 0, 4, 0, 5);
        }
        //*************************************************************************************************************************************************
        // Human
        else if (shared.Health != 0)
        {
            shared.GetUserInputs(1, 2, 3, 0, 4, 0, 5);
        }
        //*************************************************************************************************************************************************
        //Dead
        else
        {
            anm.SetBool("Attack", false); anm.SetInteger("Move", 0); anm.SetInteger("Idle", -1);
        }
    }
Пример #2
0
    void LateUpdate()
    {
        //*************************************************************************************************************************************************
        // Bone rotation
        if (!shared.IsActive)
        {
            return;
        }

        //Set const varialbes to shared script
        shared.crouch_max = MAXCROUCH;
        shared.ang_t      = ANGT;
        shared.yaw_max    = MAXYAW;
        shared.pitch_max  = MAXPITCH;

        if (shared.lastHit != 0)        //Taking damage animation
        {
            crouch = Mathf.Lerp(crouch, (MAXCROUCH * transform.localScale.x) / 2, 1.0f);
            shared.lastHit--; Head.GetChild(0).transform.rotation *= Quaternion.Euler(shared.lastHit, 0, 0);
        }
        else if (reset)        //Reset
        {
            anm.SetFloat("Turn", Mathf.Lerp(anm.GetFloat("Turn"), 0.0f, ANGT / 3));
            spineX = Mathf.Lerp(spineX, 0.0f, ANGT / 3);
            spineY = Mathf.Lerp(spineY, 0.0f, ANGT / 3);
            crouch = Mathf.Lerp(crouch, 0, ANGT / 3);
        }
        else
        {
            shared.TargetLooking(spineX, spineY, crouch);
            spineX = Mathf.Lerp(spineX, shared.spineX_T, ANGT / 3);
            spineY = Mathf.Lerp(spineY, shared.spineY_T, ANGT / 3);
            crouch = Mathf.Lerp(crouch, shared.crouch_T, ANGT);
        }

        //Save head position befor transformation
        shared.fixedHeadPos = Head.position;

        //Spine rotation
        float spineZ = spineY * spineX / MAXYAW;

        Spine0.transform.rotation *= Quaternion.Euler(-spineY, spineZ, -spineX);
        Spine1.transform.rotation *= Quaternion.Euler(-spineY, spineZ, -spineX);
        Spine2.transform.rotation *= Quaternion.Euler(-spineY, spineZ, -spineX);
        Spine3.transform.rotation *= Quaternion.Euler(-spineY, spineZ, -spineX);
        Spine4.transform.rotation *= Quaternion.Euler(-spineY, spineZ, -spineX);
        Spine5.transform.rotation *= Quaternion.Euler(-spineY, spineZ, -spineX);

        Neck0.transform.rotation *= Quaternion.Euler(-spineY, spineZ, -spineX);
        Neck1.transform.rotation *= Quaternion.Euler(-spineY, spineZ, -spineX);
        Neck2.transform.rotation *= Quaternion.Euler(-spineY, spineZ, -spineX);
        Neck3.transform.rotation *= Quaternion.Euler(-spineY, spineZ, -spineX);
        Head.transform.rotation  *= Quaternion.Euler(-spineY, spineZ, -spineX);

        //Tail rotation
        tailX = Mathf.Lerp(tailX, anm.GetFloat("Turn") * MAXYAW, ANGT / 3);
        Tail0.transform.rotation *= Quaternion.Euler(0, 0, tailX);
        Tail1.transform.rotation *= Quaternion.Euler(0, 0, tailX);
        Tail2.transform.rotation *= Quaternion.Euler(0, 0, tailX);
        Tail3.transform.rotation *= Quaternion.Euler(0, 0, tailX);
        Tail4.transform.rotation *= Quaternion.Euler(0, 0, tailX);
        Tail5.transform.rotation *= Quaternion.Euler(0, 0, tailX);
        Tail6.transform.rotation *= Quaternion.Euler(0, 0, tailX);
        Tail7.transform.rotation *= Quaternion.Euler(0, 0, tailX);
        Tail8.transform.rotation *= Quaternion.Euler(0, 0, tailX);

        //Arms rotation
        Arm1.transform.rotation *= Quaternion.Euler(spineY * 8, 0, 0);
        Arm2.transform.rotation *= Quaternion.Euler(0, spineY * 8, 0);

        //IK feet (require "JP script extension" asset)
        shared.SmallBipedIK(Right_Hips, Right_Leg, Right_Foot0, Right_Foot1, Left_Hips, Left_Leg, Left_Foot0, Left_Foot1);
        //Check for ground layer
        shared.GetGroundAlt(false, crouch);

        //*************************************************************************************************************************************************
        // CPU (require "JP script extension" asset)
        if (shared.AI && shared.Health != 0)
        {
            shared.AICore(1, 2, 3, 4, 5, 6, 7);
        }
        //*************************************************************************************************************************************************
        // Human
        else if (shared.Health != 0)
        {
            shared.GetUserInputs(1, 2, 3, 4, 5, 6, 7);
        }
        //*************************************************************************************************************************************************
        //Dead
        else
        {
            anm.SetBool("Attack", false); anm.SetInteger("Move", 0); anm.SetInteger("Idle", -1);
        }
    }