当前位置: 首页>>代码示例>>C#>>正文


C# Animator.GetFloat方法代码示例

本文整理汇总了C#中UnityEngine.Animator.GetFloat方法的典型用法代码示例。如果您正苦于以下问题:C# Animator.GetFloat方法的具体用法?C# Animator.GetFloat怎么用?C# Animator.GetFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Animator的用法示例。


在下文中一共展示了Animator.GetFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

	// Use this for initialization
	void Start () {
		
		ani = this.GetComponent<Animator> ();
		dirX = ani.GetFloat("dirX");
		dirY = ani.GetFloat("dirY");
		ani.SetBool("running", false);
	}
开发者ID:ginpedro,项目名称:InvestigationGame,代码行数:8,代码来源:PlayerController.cs

示例2: OnPhotonSerializeView

    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            // We own this player: send the others our data
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);
            anim = GetComponent< Animator >();
            stream.SendNext(anim.GetFloat("Speed"));
            stream.SendNext(anim.GetFloat("Direction"));
            stream.SendNext(anim.GetBool("Punch_L"));
            stream.SendNext(anim.GetBool("LowKick"));
            stream.SendNext(anim.GetBool("HiKick"));
            stream.SendNext(anim.GetBool("Shoryuken"));

            myThirdPersonController myC = GetComponent<myThirdPersonController>();
            stream.SendNext((int)myC._characterState);
        }
        else
        {
            // Network player, receive data
            this.correctPlayerPos = (Vector3)stream.ReceiveNext();
            this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
            anim = GetComponent< Animator >();
            anim.SetFloat("Speed",(float)stream.ReceiveNext());
            anim.SetFloat("Direction",(float)stream.ReceiveNext());
            anim.SetBool("Punch_L",(bool)stream.ReceiveNext());
            anim.SetBool("LowKick",(bool)stream.ReceiveNext());
            anim.SetBool("HiKick", (bool)stream.ReceiveNext());
            anim.SetBool("Shoryuken", (bool)stream.ReceiveNext());

            myThirdPersonController myC = GetComponent<myThirdPersonController>();
            myC._characterState = (CharacterState)stream.ReceiveNext();
        }
    }
开发者ID:aka0x0,项目名称:boomboomwrestling,代码行数:35,代码来源:NetworkCharacter.cs

示例3: OnStateEnter

  override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
  {
    m_PlayerController = animator.gameObject.GetComponent<PlayerController>();

    m_IKTransitionTime = animator.GetFloat("IKTransitionTime");
    m_MoveTime = animator.GetFloat("MoveTime");
    m_MoveTimer = 0.0f;
  }
开发者ID:juanwinsor,项目名称:BackPacker,代码行数:8,代码来源:State_HopUp.cs

示例4: Start

	// Use this for initialization
	void Start () {
        rb = GetComponent<Rigidbody2D>();
        playerAnim = GameObject.FindGameObjectWithTag("Player").GetComponent<Animator>();
        anim = GetComponent<Animator>();

        target = new Vector3(playerAnim.GetFloat("lastX"), playerAnim.GetFloat("lastY"), 0f);

        rb.velocity = target.normalized * moveSpd;

        Debug.Log(target);

    }
开发者ID:DoucheBagMIKE,项目名称:DarkZeldaUnity,代码行数:13,代码来源:PlayerMoveProjectile.cs

示例5: Start

        public void Start()
        {
            // Get the values of the parameters:
            string animatorParameter = GetParameter(0);
            animatorParameterHash = Animator.StringToHash(animatorParameter);
            targetValue = GetParameterAsFloat(1, 1);
            subject = GetSubject(2);
            duration = GetParameterAsFloat(3, 0);
            if (DialogueDebug.LogInfo) Debug.Log(string.Format("{0}: Sequencer: AnimatorFloat({1}, {2}, {3}, {4})", new System.Object[] { DialogueDebug.Prefix, animatorParameter, targetValue, subject, duration }));

            // Check the parameters:
            if (subject == null) {
                if (DialogueDebug.LogWarnings) Debug.LogWarning(string.Format("{0}: Sequencer: AnimatorFloat(): subject '{1}' wasn't found.", new System.Object[] { DialogueDebug.Prefix, GetParameter(2) }));
                Stop();
            } else {
                animator = subject.GetComponentInChildren<Animator>();
                if (animator == null) {
                    if (DialogueDebug.LogWarnings) Debug.LogWarning(string.Format("{0}: Sequencer: AnimatorFloat(): no Animator found on '{1}'.", new System.Object[] { DialogueDebug.Prefix, subject.name }));
                    Stop();
                } else if (duration < SmoothMoveCutoff) {
                    Stop();
                } else {

                    // Set up the lerp:
                    startTime = DialogueTime.time;
                    endTime = startTime + duration;
                    originalValue = animator.GetFloat(animatorParameterHash);
                }
            }
        }
开发者ID:farreltr,项目名称:OneLastSunset,代码行数:30,代码来源:SequencerCommandAnimatorFloat.cs

示例6: OnStateUpdate

	public override void OnStateUpdate(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex) 
	{

		float lCurrentSpeedFactor = animator.GetFloat("speed");
		float lTime = animatorStateInfo.normalizedTime - Mathf.Floor(animatorStateInfo.normalizedTime);
		float lBlendedTime = 0.5f - 0.25f * lCurrentSpeedFactor;

		FootPlacementData[] lFeet = animator.GetComponents<FootPlacementData>();
		FootPlacementData lFoot;

		//First foot setup start
		if(!lFeet[0].IsLeftFoot)
		{
			lFoot = lFeet[0];
		}
		else
		{
			lFoot = lFeet[1];
		}

		//Setting up transition time
		lFoot.mTransitionTime = 0.15f - (0.1f * lCurrentSpeedFactor);

		//Setting up raycast extra ray dist
		if(lTime < lBlendedTime)
		{
			lFoot.mExtraRayDistanceCheck = 0.7f;
		}
		else
		{
			lFoot.mExtraRayDistanceCheck = -0.2f;
		}
		//First foot setup end


		//Second foot setup start
		if(lFeet[0].IsLeftFoot)
		{
			lFoot = lFeet[0];
		}
		else
		{
			lFoot = lFeet[1];
		}

		//Setting up transition time
		lFoot.mTransitionTime = 0.15f - (0.1f * lCurrentSpeedFactor);

		//Setting up raycast extra ray dist
		if(lTime > 0.5 && lTime < 0.5f + lBlendedTime)
		{
			lFoot.mExtraRayDistanceCheck = 0.7f;
		}
		else
		{
			lFoot.mExtraRayDistanceCheck = -0.2f;
		}
		//Second foot setup end
	}
开发者ID:Tecaa,项目名称:Configurerer,代码行数:59,代码来源:LocomotionUpdate.cs

示例7: OnStateEnter

  override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
  {
    m_PlayerController = animator.gameObject.GetComponent<PlayerController>();

    m_MoveTimer = 0.0f;

    m_IKTransitionTime = animator.GetFloat("IKTransitionTime");
    m_MoveTime = animator.GetFloat("MoveTime");
    m_MoveDistance = animator.GetFloat("MoveDistance");

    Vector3 newPosition = animator.transform.position;
    newPosition.x -= m_MoveDistance;

    Hashtable hash = iTween.Hash("position", newPosition, "time", m_MoveTime, "easetype", iTween.EaseType.easeOutElastic);
    iTween.MoveTo(animator.gameObject, hash);

    m_IKSwitched = false;
  }
开发者ID:juanwinsor,项目名称:BackPacker,代码行数:18,代码来源:State_HopLeft.cs

示例8: OnStateUpdate

 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     float jumpLeg = animator.GetFloat("JumpLeg");
     if((rightLeg && jumpLeg >=  .7f) || (!rightLeg && jumpLeg <= -.7f))
     {
         rightLeg = !rightLeg;
         if(soundBank != null)
             soundBank.PlaySound("FootStep");
     }
 }
开发者ID:mdb5108,项目名称:JurassicParkour,代码行数:11,代码来源:StateSoundBehaviour.cs

示例9: OnStateEnter

    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        this._animator = animator;
        this._stateInfo = stateInfo;

        _baseMoveMultiplier = _animator.GetFloat("moveMultiplier");

        _thisBattleCharacter = animator.GetComponent<AbstractBattleCharacter>();
        _thisBattleCharacter.StartCoroutine(RotateAndMoveTowards(_thisBattleCharacter.gameObject));
    }
开发者ID:sjai013,项目名称:RPGv2,代码行数:11,代码来源:MoveToTargetStateMachineBehaviour.cs

示例10: PartiallyDestroy

    public static void PartiallyDestroy(Transform obj, Animator bulletAnim)
    {
        float input_x = bulletAnim.GetFloat("input_x");
        float input_y = bulletAnim.GetFloat("input_y");

        obj.NotNull((t) =>
        {
            Animator wallAnim = t.GetComponent<Animator>();

            float curr = wallAnim.GetFloat("left_numpad");

            // The tyniest piece of wall left
            if (curr.IsIn(1, 3, 7, 9))
            {
                Destroy(t.gameObject);
            }
            // Vertical shot
            else if (input_x == 0)
            {
                if (curr.IsIn(2, 8))
                {
                    Destroy(t.gameObject);
                }
                else if (curr.IsIn(4, 5, 6))
                {
                    wallAnim.SetFloat("left_numpad", curr + input_y * 3);
                }
            }
            // Horizontal shot
            else if (input_y == 0)
            {
                if (curr.IsIn(4, 6))
                {
                    Destroy(t.gameObject);
                }
                else if (curr.IsIn(2, 5, 8))
                {
                    wallAnim.SetFloat("left_numpad", curr + input_x);
                }
            }
        });
    }
开发者ID:JustoSenka,项目名称:BattleCity,代码行数:42,代码来源:BulletWallDestroy.cs

示例11: PartiallyDestroy

    private void PartiallyDestroy(Transform obj, Animator bulletAnim)
    {
        float input_x = bulletAnim.GetFloat("input_x");
        float input_y = bulletAnim.GetFloat("input_y");

        obj.NotNull((t) =>
        {
            Animator wallAnim = t.GetComponent<Animator>();

            float curr = wallAnim.GetFloat("left_numpad");

            // Strong shot will allways destroy a piece (and maybe two)
            Destroy(t.gameObject);

            // Horizontal shot
            if (input_x == 1 && curr.IsIn(3, 6, 9))
            {
                obj.position += new Vector3(1, 0, 0);
                BulletWallDestroy.PartiallyDestroy(ts.GetByNameAndCoords
                    ("Wall", obj.position.x, obj.position.y), bulletAnim);
            }
            if (input_x == -1 && curr.IsIn(1, 4, 7))
            {
                obj.position += new Vector3(-1, 0, 0);
                BulletWallDestroy.PartiallyDestroy(ts.GetByNameAndCoords
                    ("Wall", obj.position.x, obj.position.y), bulletAnim);
            }
            // Vertical shot
            if (input_y == 1 && curr.IsIn(7, 8, 9))
            {
                obj.position += new Vector3(0, 1, 0);
                BulletWallDestroy.PartiallyDestroy(ts.GetByNameAndCoords
                    ("Wall", obj.position.x, obj.position.y), bulletAnim);
            }
            if (input_y == -1 && curr.IsIn(1, 2, 3))
            {
                obj.position += new Vector3(0, -1, 0);
                BulletWallDestroy.PartiallyDestroy(ts.GetByNameAndCoords
                    ("Wall", obj.position.x, obj.position.y), bulletAnim);
            }
        });
    }
开发者ID:JustoSenka,项目名称:BattleCity,代码行数:42,代码来源:BulletIronDestroy.cs

示例12: GetXAxisForce

    private float GetXAxisForce(Animator animator)
    {
        float xForce =50f;
        if(animator.GetBool(PLATFORM_PARAMETER))
        {
            xForce = 0f;
        }
        if (animator.GetBool(HOLE_PARAMATER))
        {
            xForce = 150f;

            Vector2 newVelocity = mBody.velocity;
            newVelocity.x =  Mathf.Sign(animator.GetFloat("Speed")) * 7f;
            mBody.velocity = newVelocity;
        }

        xForce *= Mathf.Sign(animator.GetFloat("Speed"));

        return xForce;
    }
开发者ID:ysucae,项目名称:Balloune,代码行数:20,代码来源:JumpingState.cs

示例13: OnStateMove

    public override void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        float speed = animator.GetFloat(SPEED_PARAMATER);

        if (speed != 0)
        {
            Move(speed);
        }

        CheckFlipping(speed);
    }
开发者ID:ysucae,项目名称:Balloune,代码行数:11,代码来源:MovingState.cs

示例14: OnStateEnter

    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        bool OnGround = animator.GetBool("OnGround");
        float jumpVal = animator.GetFloat("Jump");

        if(OnGround && jumpVal > -2)
        {
            //if(soundBank != null)
            //    soundBank.PlaySound("Land");
        }
    }
开发者ID:mdb5108,项目名称:JurassicParkour,代码行数:12,代码来源:StateSoundBehaviour.cs

示例15: OnStateMove

    // OnStateMove is called right after Animator.OnAnimatorMove(). Code that processes and affects root motion should be implemented here
    public override void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        // play talk and idle sound
        talkSound.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(animator.gameObject.transform));
        idleSound.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(animator.gameObject.transform));
        if ((animator.GetFloat("Speed") != 1) && (animator.GetFloat("vSpeed") == 0))
        {
            talkSound.setVolume(1);
            idleSound.setVolume(1);
        }
        else
        {
            talkSound.setVolume(0);
            idleSound.setVolume(0);
        }

        // play roll sound according to speed parameter
        rollSound.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(animator.gameObject.transform));
        rollSound.setParameterValue("speed", animator.GetFloat("Speed"));
        // play leaves sound
        leavesSound.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(animator.gameObject.transform));
        leavesSound.setParameterValue("speed", animator.GetFloat("Speed"));

        // play jump sound (oneshot)
        if ((animator.GetFloat("vSpeed") > 11) && (playOnceJump == true))
        {
            FMODUnity.RuntimeManager.PlayOneShot("event:/robo_jump", animator.gameObject.transform.position);
            playOnceJump = false;
            playOnceLand = true;
            leavesSound.setVolume(0);
        }

        // play land sound (oneshot)
        if ((animator.GetFloat("vSpeed") < -5) && (playOnceLand == true))
        {
            FMODUnity.RuntimeManager.PlayOneShot("event:/robo_land", animator.gameObject.transform.position);
            playOnceLand = false;
            playOnceJump = true;
            leavesSound.setVolume(1);
        }
    }
开发者ID:BlackhawkAceX,项目名称:GameOn-TheWayHome,代码行数:42,代码来源:RoboBehaviour.cs


注:本文中的UnityEngine.Animator.GetFloat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。