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


C# Animator.SetFloat方法代码示例

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


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

示例1: OnStateEnter

 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     Vector2 movement = animator.GetComponent<MobMotion>().PendingMovement;
     movement.Normalize();
     animator.SetFloat(MovX, movement.x);
     animator.SetFloat(MovY, movement.y);
 }
开发者ID:TheGovernorsJunk,项目名称:CaulsCastle,代码行数:7,代码来源:DodgeBehaviour.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

	 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
	override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
		base.OnStateEnter (animator, stateInfo, layerIndex);
		animator.SetFloat (AnimatorConstants.MOVING,Random.value + 0.25f);
		animator.SetFloat (AnimatorConstants.ORTHO, Random.value);
		_rotation = Random.value < 0.5f ? Quaternion.Euler (0, 0, 90) : Quaternion.Euler (0, 0, -90);

	}
开发者ID:kunodev,项目名称:GGJ2016,代码行数:8,代码来源:OrthoMove.cs

示例4: BeginAttack

 public void BeginAttack()
 {
     agent = GetComponent<NavMeshAgent> ();
     Component[] animatorComponents = GetComponentsInChildren<Animator> ();
     anim = animatorComponents [0] as Animator; // there only exists one animator component
     //BeginAttack();
     attackStarted = true;
     gameObject.SetActive (true);
     agent.SetDestination (attackTarget.position);
     anim.SetFloat ("Walk", 1);
     anim.SetFloat ("Run", 1);
 }
开发者ID:MatthewBregg,项目名称:VRProject2,代码行数:12,代码来源:AttackerAgentScript.cs

示例5: OnStateUpdate

 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     MobMotion motion = animator.GetComponent<MobMotion>();
     Vector2 movement = motion.PendingMovement;
     animator.SetFloat(MovX, movement.x);
     animator.SetFloat(MovY, movement.y);
 }
开发者ID:TheGovernorsJunk,项目名称:CaulsCastle,代码行数:7,代码来源:MoveBehaviour.cs

示例6: Start

 // Use this for initialization
 void Start () {
     _axeRes = Resources.Load("Battle_axe") as GameObject;
     Debug.Log(_axeRes);
     _mover = GetComponent<MoveScript>();
     _anim = GetComponent<Animator>();
     _health = GetComponent<HealthScript>();
     _anim.SetFloat("SpeedX", 0);
     _anim.SetFloat("SpeedY", -1);
 }
开发者ID:nitesuit,项目名称:2DMultiplayerGame,代码行数:10,代码来源:PlayerController.cs

示例7: Enter

 public override void Enter()
 {
     PlayerBehaviorStateMachine SM = (PlayerBehaviorStateMachine)GetStateMachine();
     m_Animator = SM.m_GameObject.GetComponent<Animator>();
     m_Animator.SetBool("OnGround", true);
     m_Animator.SetFloat("Jump", 0.0f);
     m_Animator.SetFloat("Turn", 0.0f, 0.1f, Time.deltaTime);
     m_Animator.applyRootMotion = false;
 }
开发者ID:rcrmn,项目名称:mastervj-unity-minigames,代码行数:9,代码来源:PlayerState_Alive_AnimationManager_Walk.cs

示例8: OnEnter

		public override void OnEnter ()
		{
			animator = ownerDefault.GetComponent<UnityEngine.Animator> ();

			if (dampTime > 0) {
				animator.SetFloat (hash, owner.GetValue(value), dampTime, Time.deltaTime);
			} else {
				animator.SetFloat (hash,  owner.GetValue(value));
			}
			Finish ();
		}
开发者ID:NusantaraBeta,项目名称:BrawlerRumble,代码行数:11,代码来源:SetFloat.cs

示例9: ShotAnimation

    private void ShotAnimation(Animator archer, Transform target)
    {
        Vector2 targetPos = new Vector2(target.position.x, target.position.y);
        Vector2 archerPos = new Vector2(archer.transform.position.x, archer.transform.position.y);

        Vector2 direction = (targetPos - archerPos).normalized;

        archer.SetFloat("AttackDirectionX", direction.x);
        archer.SetFloat("AttackDirectionY", direction.y);
        archer.SetTrigger("AttackTrigger");
    }
开发者ID:pan4,项目名称:NewTD,代码行数:11,代码来源:MT_Controller.cs

示例10: OnStateUpdate

	// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
	override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
		GameObject[] players = GameObject.FindGameObjectsWithTag ("Player");
		Attack attack = animator.GetComponent<AttackQueue> ().Attack;
		Enemy enem = animator.GetComponent<Enemy> ();
		Vector3 fromTo = enem.Target.transform.position - animator.transform.position;
		if (fromTo.magnitude <= attack.collSize.magnitude) {
			animator.SetFloat (AnimatorConstants.PUNCH, Random.value);
		} else {
			animator.SetFloat (AnimatorConstants.PUNCH, 0f);
		}
	}
开发者ID:kunodev,项目名称:GGJ2016,代码行数:12,代码来源:BaseStateMachineScript.cs

示例11: Init

    void Init()
    {
        agent = GetComponent<NavMeshAgent>();
        animator = GetComponent<Animator>();
        weapon = GameObject.Find("Weapon").GetComponent<WeaponScript>();
        target = GameObject.Find("Player").transform;

        animator.SetFloat("X", 0);
        animator.SetFloat("Y", 0);

        phase = 1;
    }
开发者ID:wjSimon,项目名称:GD1014_s3p,代码行数:12,代码来源:Boss.cs

示例12: Init

	private void Init(){
		Invoke("activation",2f);
		master.setLayer("tower",this.gameObject);
		lifebar = master.getChildFrom("Lifebar", this.gameObject);
		auxbar = lifebar.transform.localScale;
		_animator = this.gameObject.GetComponent<Animator> ();
		_animator.SetBool ("walk", false);
        _animator.SetFloat("WalkDirectionX", 0f);
        _animator.SetFloat("WalkDirectionY", -1f);

        _animator.SetBool ("dead", false);
		_animator.SetBool ("attack", false);
	}
开发者ID:pan4,项目名称:NewTD,代码行数:13,代码来源:Knights_Controller.cs

示例13: FixedUpdate

    // Update is called once per frame
    void FixedUpdate()
    {
        onLadder = Physics2D.OverlapCircle (groundCheck.position, ladderRadius, whatIsLadder);
        anim = GetComponent<Animator>();
        float move = Input.GetAxis ("Horizontal");
        float moveY = Input.GetAxis ("Vertical");

        if (!dead) {

            if (grounded) {

                rigidbody2D.velocity = new Vector2 (((Input.GetButton("Run") || (Input.GetAxis("Run") > 0.5f))? (maxSpeed + boost) : maxSpeed) * move ,
               	                                    rigidbody2D.velocity.y);

            }
            if (onLadder) {
                anim.SetFloat ( "SpeedY", moveY );
                rigidbody2D.velocity = new Vector2 (rigidbody2D.velocity.x, moveY * maxSpeed);

            } else {
                anim.SetFloat ( "SpeedY", 0 );
            }
            if (!grounded && !onLadder) {
                rigidbody2D.velocity = new Vector2 (((Input.GetButton("Run") || (Input.GetAxis("Run") > 0.5f))? (maxSpeed + boost) : maxSpeed) * move ,
                                                    rigidbody2D.velocity.y);

            }
            characterRunning = (( move < -0.9f || move > 0.9f) && (Input.GetButton ("Run") || (Input.GetAxis ("Run") > 0.5f)));

            anim.SetFloat("Speed", Mathf.Abs (move));
            anim.SetBool ("running", characterRunning);
            anim.SetBool ("jumping", !(grounded));
            anim.SetBool ("dead", dead);
            anim.SetBool ("onLadder", onLadder);
            anim.SetBool ("onLadderMoving", (onLadder && ( Mathf.Abs (move) !=0 || moveY != 0 )));
            if (Input.GetButtonDown ("Attack")){
                StartCoroutine(SwordAttack());
            }
            anim.SetBool ("sword", Input.GetButtonDown ("Attack"));

            if (move > 0 &&!facingRight){
                Flip ();
                facingRight = true;
            }else if (move < 0 && facingRight){
                Flip ();
                facingRight = false;
            }
        }
    }
开发者ID:r2d32,项目名称:Unity5_CSharp_Videogame,代码行数:50,代码来源:LinkController.cs

示例14: OnStateUpdate

    //OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        // Patrolling
        if(rb != null)
            rb.velocity = (new Vector2(x, y) * 1f).normalized;

        if (rb.transform.position != lastPos)
        {
            Vector3 direction = rb.transform.position - lastPos;
            direction.Normalize();
            animator.SetFloat("DirectionX", direction.x);
            animator.SetFloat("DirectionY", direction.y);
        }
        lastPos = rb.transform.position;
    }
开发者ID:SMBNoog,项目名称:IsleOfAdventure,代码行数:16,代码来源:PatrolllingSMB.cs

示例15: Move

    //public void Move(Vector2 movement_vector, Animator anim, Rigidbody2D rbody)
    //{
    //    if (movement_vector != Vector2.zero)
    //    {
    //        anim.SetBool("isWalking", true);
    //        anim.SetFloat("input_x", movement_vector.x);
    //        anim.SetFloat("input_y", movement_vector.y);
    //    }
    //    else
    //    {
    //        anim.SetBool("isWalking", false);
    //    }
    //    rbody.MovePosition(rbody.position + movement_vector * Time.deltaTime);
    //}
    public void Move(Vector2 movement_vector, Animator anim, Rigidbody2D rbody, float speed)
    {
        if (movement_vector != Vector2.zero)
        {
            anim.SetBool("isWalking", true);
            anim.SetFloat("input_x", movement_vector.x);
            anim.SetFloat("input_y", movement_vector.y);
        }
        else
        {
            anim.SetBool("isWalking", false);
        }

        rbody.MovePosition(rbody.position + movement_vector * speed * Time.deltaTime);
    }
开发者ID:RubenVO,项目名称:Dank-Rpg,代码行数:29,代码来源:Character.cs


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