當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。