SetLookAtWeight() public method

public SetLookAtWeight ( float weight ) : void
weight float
return void
コード例 #1
0
 public override void OnAnimatorIK(int layerIndex)
 {
     position = useGlobal ? ((GameObjectParameter)owner.GetParameter(globalPosition)).Value.transform.position : position;
     animator.SetLookAtWeight(weight, bodyWeight, headWeight, eyesWeight, clampWeight);
     animator.SetLookAtPosition(position);
     Finish();
 }
コード例 #2
0
ファイル: PlayerModel.cs プロジェクト: BreakoutStudio/Test
    void OnEnable()
    {
        position = transform.position;
        rotation = transform.rotation;

        aimAt = position + transform.forward * 1000.0f;

        multiMesh = GetComponent<SkinnedMultiMesh>();
        animator = GetComponent<Animator>();

        if ( animator != null )
        {
            animator.SetLookAtPosition( Vector3.zero );
            animator.SetLookAtWeight( 1.0f, 0.0f, 1.0f, 1.0f, 0.5f );
        }
    }
コード例 #3
0
ファイル: BotControlScript.cs プロジェクト: Jeace/ADGLADIUM
    private AnimatorStateInfo layer2CurrentState; // a reference to the current state of the animator, used for layer 2

    #endregion Fields

    #region Methods

    void FixedUpdate()
    {
        anim = GetComponent<Animator>();
        float h = Input.GetAxis("Horizontal");				// setup h variable as our horizontal input axis
        float v = Input.GetAxis("Vertical");				// setup v variables as our vertical input axis
        anim.SetFloat("Speed", v);							// set our animator's float parameter 'Speed' equal to the vertical input axis
        anim.SetFloat("Direction", h); 						// set our animator's float parameter 'Direction' equal to the horizontal input axis
        anim.speed = animSpeed;								// set the speed of our animator to the public variable 'animSpeed'
        anim.SetLookAtWeight(lookWeight);					// set the Look At Weight - amount to use look at IK vs using the head's animation
        currentBaseState = anim.GetCurrentAnimatorStateInfo(0);	// set our currentState variable to the current state of the Base Layer (0) of animation

        if(anim.layerCount ==2)
            layer2CurrentState = anim.GetCurrentAnimatorStateInfo(1);	// set our layer2CurrentState variable to the current state of the second Layer (1) of animation

        // LOOK AT ENEMY

        // if we hold Alt..
        if(Input.GetButton("Fire2"))
        {
            // ...set a position to look at with the head, and use Lerp to smooth the look weight from animation to IK (see line 54)
            anim.SetLookAtPosition(enemy.position);
            lookWeight = Mathf.Lerp(lookWeight,1f,Time.deltaTime*lookSmoother);
        }
        // else, return to using animation for the head by lerping back to 0 for look at weight
        else
        {
            lookWeight = Mathf.Lerp(lookWeight,0f,Time.deltaTime*lookSmoother);
        }

        // STANDARD JUMPING

        // if we are currently in a state called Locomotion (see line 25), then allow Jump input (Space) to set the Jump bool parameter in the Animator to true
        /*if (currentBaseState.nameHash == locoState)
        {*/
            if(Input.GetButtonDown("Jump"))
            {
                anim.SetBool("Jump", true);
            }
        //}

        // if we are in the jumping state...
        else if(currentBaseState.nameHash == jumpState)
        {
            //  ..and not still in transition..
            if(!anim.IsInTransition(0))
            {
                /*if(useCurves)
                    // ..set the collider height to a float curve in the clip called ColliderHeight
                    col.height = anim.GetFloat("ColliderHeight");*/

                // reset the Jump bool so we can jump again, and so that the state does not loop
                anim.SetBool("Jump", false);
            }

            // Raycast down from the center of the character..
            Ray ray = new Ray(transform.position + Vector3.up, -Vector3.up);
            RaycastHit hitInfo = new RaycastHit();

            if (Physics.Raycast(ray, out hitInfo))
            {
                // ..if distance to the ground is more than 1.75, use Match Target
                if (hitInfo.distance > 1.75f)
                {

                    // MatchTarget allows us to take over animation and smoothly transition our character towards a location - the hit point from the ray.
                    // Here we're telling the Root of the character to only be influenced on the Y axis (MatchTargetWeightMask) and only occur between 0.35 and 0.5
                    // of the timeline of our animation clip
                    anim.MatchTarget(hitInfo.point, Quaternion.identity, AvatarTarget.Root, new MatchTargetWeightMask(new Vector3(0, 1, 0), 0), 0.35f, 0.5f);
                }
            }
        }

        // JUMP DOWN AND ROLL

        // if we are jumping down, set our Collider's Y position to the float curve from the animation clip -
        // this is a slight lowering so that the collider hits the floor as the character extends his legs
        else if (currentBaseState.nameHash == jumpDownState)
        {
            col.center = new Vector3(0, anim.GetFloat("ColliderY"), 0);
        }

        // if we are falling, set our Grounded boolean to true when our character's root
        // position is less that 0.6, this allows us to transition from fall into roll and run
        // we then set the Collider's Height equal to the float curve from the animation clip
        else if (currentBaseState.nameHash == fallState)
        {
            col.height = anim.GetFloat("ColliderHeight");
        }

        // if we are in the roll state and not in transition, set Collider Height to the float curve from the animation clip
        // this ensures we are in a short spherical capsule height during the roll, so we can smash through the lower
        // boxes, and then extends the collider as we come out of the roll
        // we also moderate the Y position of the collider using another of these curves on line 128
        else if (currentBaseState.nameHash == rollState)
        {
            if(!anim.IsInTransition(0))
            {
                if(useCurves)
                    col.height = anim.GetFloat("ColliderHeight");

                col.center = new Vector3(0, anim.GetFloat("ColliderY"), 0);

            }
        }
        // IDLE
        /*
        // check if we are at idle, if so, let us Wave!
        else if (currentBaseState.nameHash == idleState)
        {
            if(Input.GetButtonUp("Jump"))
            {
                anim.SetBool("Wave", true);
            }
        }
        // if we enter the waving state, reset the bool to let us wave again in future
        if(layer2CurrentState.nameHash == waveState)
        {
            anim.SetBool("Wave", false);
        }
        */
    }
コード例 #4
0
ファイル: Player.cs プロジェクト: francoisvdv/PungSeon
    // Use this for initialization
    void Start()
    {
        Health = Options.StartingHealth;

        laserTarget = transform.Search("LaserTarget");

        eyesL = transform.Search("EyeL");
        eyesR = transform.Search("EyeR");

        laserBeamL = eyesL.Find("LaserParticles");
        laserBeamR = eyesR.Find("LaserParticles");

        // initialising reference variables
        anim = GetComponent<Animator>();
        col = GetComponent<CapsuleCollider>();

        anim.SetLookAtWeight(1);
        if (anim.layerCount == 2)
            anim.SetLayerWeight(1, 1);

        NetworkManager.Instance.Client.AddListener(this);
    }
コード例 #5
0
 public override void OnAnimatorIK(int layerIndex)
 {
     animator.SetLookAtWeight(owner.GetValue(weight), owner.GetValue(bodyWeight), owner.GetValue(headWeight), owner.GetValue(eyesWeight), owner.GetValue(clampWeight));
     animator.SetLookAtPosition(owner.GetValue(position));
     Finish();
 }
        private void OnAnimatorIK(int layerIndex)
        {
            if (animator != null)
            {
                animator.SetLookAtWeight(lookAtWeight, lookAtBodyWeight, lookAtHeadWeight, lookAtEyesWeight, lookAtClampWeight);
                animator.SetLookAtPosition(lookAtPosition);

                animator.SetIKPositionWeight(AvatarIKGoal.RightHand, rightHandPosWeight);
                animator.SetIKPositionWeight(AvatarIKGoal.LeftHand, leftHandPosWeight);
                animator.SetIKPositionWeight(AvatarIKGoal.RightFoot, rightFootPosWeight);
                animator.SetIKPositionWeight(AvatarIKGoal.LeftFoot, leftFootPosWeight);

                animator.SetIKRotationWeight(AvatarIKGoal.RightHand, rightHandRotWeight);
                animator.SetIKRotationWeight(AvatarIKGoal.LeftHand, leftHandRotWeight);
                animator.SetIKRotationWeight(AvatarIKGoal.RightFoot, rightFootRotWeight);
                animator.SetIKRotationWeight(AvatarIKGoal.LeftFoot, leftFootRotWeight);

                animator.SetIKHintPositionWeight(AvatarIKHint.RightElbow, rightElbowPosWeight);
                animator.SetIKHintPositionWeight(AvatarIKHint.LeftElbow, leftElbowPosWeight);
                animator.SetIKHintPositionWeight(AvatarIKHint.RightKnee, rightKneePosWeight);
                animator.SetIKHintPositionWeight(AvatarIKHint.LeftKnee, leftKneePosWeight);

                animator.SetIKPosition(AvatarIKGoal.RightHand, rightHandPos);
                animator.SetIKPosition(AvatarIKGoal.LeftHand, leftHandPos);
                animator.SetIKPosition(AvatarIKGoal.RightFoot, rightFootPos);
                animator.SetIKPosition(AvatarIKGoal.LeftFoot, leftFootPos);

                animator.SetIKHintPosition(AvatarIKHint.RightElbow, rightElbowPos);
                animator.SetIKHintPosition(AvatarIKHint.LeftElbow, leftElbowPos);
                animator.SetIKHintPosition(AvatarIKHint.RightKnee, rightKneePos);
                animator.SetIKHintPosition(AvatarIKHint.LeftKnee, leftKneePos);

                animator.SetIKRotation(AvatarIKGoal.RightHand, rightHandRot);
                animator.SetIKRotation(AvatarIKGoal.LeftHand, leftHandRot);
                animator.SetIKRotation(AvatarIKGoal.RightFoot, rightFootRot);
                animator.SetIKRotation(AvatarIKGoal.LeftFoot, leftFootRot);

                internalLeftFootPos  = animator.GetIKPosition(AvatarIKGoal.LeftFoot);
                internalRightFootPos = animator.GetIKPosition(AvatarIKGoal.RightFoot);
                internalLeftHandPos  = animator.GetIKPosition(AvatarIKGoal.LeftHand);
                internalRightHandPos = animator.GetIKPosition(AvatarIKGoal.RightHand);

                internalLeftFootRot  = animator.GetIKRotation(AvatarIKGoal.LeftFoot);
                internalRightFootRot = animator.GetIKRotation(AvatarIKGoal.RightFoot);
                internalLeftHandRot  = animator.GetIKRotation(AvatarIKGoal.LeftHand);
                internalRightHandRot = animator.GetIKRotation(AvatarIKGoal.RightHand);

                internalLeftKneePos   = animator.GetIKHintPosition(AvatarIKHint.LeftKnee);
                internalRightKneePos  = animator.GetIKHintPosition(AvatarIKHint.RightKnee);
                internalLeftElbowPos  = animator.GetIKHintPosition(AvatarIKHint.LeftElbow);
                internalRightElbowPos = animator.GetIKHintPosition(AvatarIKHint.RightElbow);


                internalLeftFootPosWeight  = animator.GetIKPositionWeight(AvatarIKGoal.LeftFoot);
                internalRightFootPosWeight = animator.GetIKPositionWeight(AvatarIKGoal.RightFoot);
                internalLeftHandPosWeight  = animator.GetIKPositionWeight(AvatarIKGoal.LeftHand);
                internalRightHandPosWeight = animator.GetIKPositionWeight(AvatarIKGoal.RightHand);

                internalLeftFootRotWeight  = animator.GetIKRotationWeight(AvatarIKGoal.LeftFoot);
                internalRightFootRotWeight = animator.GetIKRotationWeight(AvatarIKGoal.RightFoot);
                internalLeftHandRotWeight  = animator.GetIKRotationWeight(AvatarIKGoal.LeftHand);
                internalRightHandRotWeight = animator.GetIKRotationWeight(AvatarIKGoal.RightHand);

                internalLeftKneeWeight   = animator.GetIKHintPositionWeight(AvatarIKHint.LeftKnee);
                internalRightKneeWeight  = animator.GetIKHintPositionWeight(AvatarIKHint.RightKnee);
                internalLeftElbowWeight  = animator.GetIKHintPositionWeight(AvatarIKHint.LeftElbow);
                internalRightElbowWeight = animator.GetIKHintPositionWeight(AvatarIKHint.RightElbow);
            }
        }