當前位置: 首頁>>代碼示例>>C#>>正文


C# UnityEngine.AnimatorStateInfo類代碼示例

本文整理匯總了C#中UnityEngine.AnimatorStateInfo的典型用法代碼示例。如果您正苦於以下問題:C# AnimatorStateInfo類的具體用法?C# AnimatorStateInfo怎麽用?C# AnimatorStateInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AnimatorStateInfo類屬於UnityEngine命名空間,在下文中一共展示了AnimatorStateInfo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: 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)
    {
        if(animator.gameObject.GetComponent<Enemy>().indexPos == 0){
            if(animator.GetInteger("attack") == 1){
                GameObject EarthBend = (GameObject)Instantiate(Resources.Load("EarthBend", typeof(GameObject)), GameObject.Find("skillSpawn(1)").transform.position, GameObject.Find("skillSpawn(1)").transform.rotation);
                EarthBend.GetComponent<Rigidbody>().velocity = EarthBend.transform.TransformDirection(Vector3.forward * 15);
                EarthBend.transform.FindChild("source").gameObject.tag = "Enemy1Attack";
            }
        }

        if(animator.gameObject.GetComponent<Enemy>().indexPos == 1){
            if(animator.GetInteger("attack") == 1){
                GameObject EarthBend = (GameObject)Instantiate(Resources.Load("EarthBend", typeof(GameObject)), GameObject.Find("skillSpawn(2)").transform.position, GameObject.Find("skillSpawn(2)").transform.rotation);
                EarthBend.GetComponent<Rigidbody>().velocity = EarthBend.transform.TransformDirection(Vector3.forward * 15);
                EarthBend.transform.FindChild("source").gameObject.tag = "Enemy2Attack";
            }
        }

        if(animator.gameObject.GetComponent<Enemy>().indexPos == 2){
            if(animator.GetInteger("attack") == 1){
                GameObject EarthBend = (GameObject)Instantiate(Resources.Load("EarthBend", typeof(GameObject)), GameObject.Find("skillSpawn(3)").transform.position, GameObject.Find("skillSpawn(3)").transform.rotation);
                EarthBend.GetComponent<Rigidbody>().velocity = EarthBend.transform.TransformDirection(Vector3.forward * 15);
                EarthBend.transform.FindChild("source").gameObject.tag = "Enemy3Attack";

            }
        }
    }
開發者ID:oonyeje,項目名稱:BendingTempleAssets,代碼行數:28,代碼來源:EarthAttack.cs

示例2: OnStateExit

 // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
 public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     // In case it is not destroyed for some reason when it depends on the animation
     if (DependOnThisState && _spawnedGameObject != null) {
         Destroy(_spawnedGameObject);
     }
 }
開發者ID:SpoonmanGames,項目名稱:Descend-Into-Heaven,代碼行數:8,代碼來源:SpawnBehaviour.cs

示例3: GetAnimatorNameHash

		public static int GetAnimatorNameHash(AnimatorStateInfo animatorStateInfo) {
			#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
			return animatorStateInfo.nameHash;
			#else
			return animatorStateInfo.fullPathHash;
			#endif
		}
開發者ID:gorco,項目名稱:LaCortesiaDeEspa-a,代碼行數:7,代碼來源:UITools.cs

示例4: OnStateUpdate

	override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
	{
		FootPlacementData lF1 = animator.GetComponents<FootPlacementData>()[0];
		FootPlacementData lF2 = animator.GetComponents<FootPlacementData>()[1];

		//setting up first foot transition time and extra ray dist check
		if (lF1 != null)
		{
			if(stateInfo.normalizedTime  > 0.25f)
			{
				lF1.mExtraRayDistanceCheck = mIdleRayCast;
			}
			else
			{
				lF1.mExtraRayDistanceCheck = 0;
			}
		}

		//setting up second foot transition time and extra ray dist check
		if (lF2 != null)
		{
			if(stateInfo.normalizedTime  > 0.25f)
			{
				lF2.mExtraRayDistanceCheck = mIdleRayCast;
			}
			else
			{
				lF2.mExtraRayDistanceCheck = 0;
			}
		}
	}
開發者ID:Tecaa,項目名稱:Configurerer,代碼行數:31,代碼來源:IdleUpdate.cs

示例5: UpdateAnimator

    //**********************************************************************************//
    // ANIMATOR			      															//
    // update animations at the animator controller (Mecanim)							//
    //**********************************************************************************//
    public void UpdateAnimator()
    {
        if (ragdolled)
            DisableActions();
        else
        {
            stateInfo = animator.GetCurrentAnimatorStateInfo(0);
            actions = jumpOver || stepUp || climbUp || rolling;

            RandomIdle();
            RollForwardAnimation();
            QuickTurn180Animation();
            QuickStopAnimation();
            LandHighAnimation();
            JumpOverAnimation();
            ClimbUpAnimation();
            StepUpAnimation();

            ControlLocomotion();

            animator.SetBool("Aiming", aiming);
            animator.SetBool("Crouch", crouch);
            animator.SetBool("OnGround", onGround);
            animator.SetFloat("GroundDistance", groundDistance);
            animator.SetFloat("VerticalVelocity", verticalVelocity);
        }
    }
開發者ID:noahzaozao,項目名稱:Mud7_iWorld,代碼行數:31,代碼來源:ThirdPersonAnimator.cs

示例6: OnStateEnter

 public override void OnStateEnter(
     Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     this.animator = animator;
     GameManager.PlayerInteraction.PowerupOn += OnPlayerPowerupOn;
     GameManager.PlayerInteraction.PowerupOff += OnPlayerPowerupOff;
 }
開發者ID:rharel,項目名稱:unity-pacman,代碼行數:7,代碼來源:GhostPowerupAnimation.cs

示例7: 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)
 {
     Debug.Log("Stop");
     var rigidbody = animator.GetComponentInParent<Rigidbody>();
     store = rigidbody.constraints;
     rigidbody.constraints = RigidbodyConstraints.FreezeAll;
 }
開發者ID:bergerbo,項目名稱:ggj2016,代碼行數:8,代碼來源:StopVelocity.cs

示例8: Update

 // Update is called once per frame
 void Update()
 {
     time += Time.deltaTime;
     info = ani.GetCurrentAnimatorStateInfo(0);
     if (audio.isPlaying == false&&motionflag == false && time > 3.0f)
     {
         if (Life > 20)
         {
             audio.clip = okok;
             audio.Play();
             ani.SetTrigger("Win");
             motionflag = true;
         }
         else
         {
             audio.clip = nooo;
             audio.Play();
             ani.SetTrigger("Lose");
             motionflag = true;
         }
     }
     if (info.IsName("WIN00") || info.IsName("LOSE00"))
     {
         if (info.normalizedTime > 1.0f&&byeflag == false && time > 5.0f)
         {
             ani.SetTrigger("bye");
             audio.clip = bye;
             audio.Play();
             byeflag = true;
         }
     }
 }
開發者ID:akihiro0105,項目名稱:Fu-Fu-UnityChan,代碼行數:33,代碼來源:UnityChan_Control.cs

示例9: OnStateEnter

	public RomanCharState.State characterState;	// Which state to switch into on enter
	 
	 // 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) 
	{
		GameManager.Instance.charState.SetState(characterState);
//		RSUtil.Instance.DelayedAction (() => {
//			GameManager.Instance.charState.SetState(characterState);
//		}, 0.2f);
	}
開發者ID:pencilking2002,項目名稱:TOF_Movement_Protype,代碼行數:10,代碼來源:SetState.cs

示例10: Update

    void Update()
    {
        _startN = 0.0f;
        _endN = 0.0f;
        _animationState = mAnimator.GetCurrentAnimatorStateInfo (0);

        SwoonNode snode = System.Array.Find (_animations, xx => _animationState.IsName (xx.clipname));
        if (snode != null)
        {
            _time = _animationState.normalizedTime - Mathf.Floor(_animationState.normalizedTime);
            float frames = (int)(_animationState.length*30);
            _startN = snode.start / frames;
            _endN = snode.end / frames;
            if (_time >= _startN && _time < _endN)
            {
                _trails.ForEach(x=>x.Emit = true);
            }
            else
            {
                _trails.ForEach(x=>x.Emit = false);
            }
        }
        else
        {
            _time = 0f;
            //_prevTime = _time;
            //_prevAnimTime = 0f;
        }
    }
開發者ID:bmjoy,項目名稱:u3dutility,代碼行數:29,代碼來源:SwooshNew.cs

示例11: OnStateExit

    // 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) {
    //
    //}
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}
    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        myBoxCollider = animator.GetComponent<PlayerController>().mySwordBoxCollider;
        myBoxCollider.enabled = false;

        animator.SetBool("Whirlwinding", false);
    }
開發者ID:Unityprojektgruppe2,項目名稱:Unity-Project---Group-2-NEW,代碼行數:16,代碼來源:WhirlwindStopAnimationBehaviour.cs

示例12: OnStateUpdate

 // 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) {
 //
 //}
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateinfo, int layerindex)
 {
     if (Player.Instance.OnGround) {
         animator.SetBool("land", false);
         animator.ResetTrigger("jump");
     }
 }
開發者ID:sircuddles,項目名稱:inScope-Studios-2D-Platformer,代碼行數:12,代碼來源:LandBehavior.cs

示例13: OnStateUpdate

	// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
	override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
		Vector3 newPos = originalPos;
		
		newPos.y = newPos.y + yOffset;
		
		animator.transform.position = newPos;
	}
開發者ID:Subsuperhuman,項目名稱:Solstice,代碼行數:8,代碼來源:offset.cs

示例14: Update

	// Update is called once per frame
	void Update () {
		//Debug.Log(anim.GetCurrentAnimatorStateInfo(0).tagHash.ToString());

		asi = anim.GetCurrentAnimatorStateInfo (0);
		if (asi.IsName ("Still Scenes")) {
			if(!a1HasPlayed){
				audSource.PlayOneShot (a1,2f);
				a1HasPlayed = true;
			}
		}else if (asi.IsName ("Still Scene 2")) {
			if(!a2HasPlayed){
				audSource.PlayOneShot (a2,1f);
				a2HasPlayed = true;
			}
		}else if (asi.IsName ("Still Scene 3")) {
			if(!a3HasPlayed){
				audSource.PlayOneShot (a3,1f);
				a3HasPlayed = true;
			}
		}else if (asi.IsName ("Cutscene Still 4")) {
			if(!a4HasPlayed){
				audSource.PlayOneShot (a4,1f);
				a4HasPlayed = true;
			}
		}

		if ( a4HasPlayed && !audSource.isPlaying )
			SceneManager.LoadScene ( "Instructions" );
	}
開發者ID:ecaraway,項目名稱:Global-Game-Jam-2016,代碼行數:30,代碼來源:CutsceneAudio.cs

示例15: FixedUpdate

    void FixedUpdate()
    {
        currentBaseState = animator.GetCurrentAnimatorStateInfo(0); //Indica la capa de animacion
        int currentState = currentBaseState.nameHash;
        int state = (int)states.currentState;
        animator.SetFloat("Direction",Input.GetAxis("Horizontal"));
        animator.SetFloat("Speed",Input.GetAxis("Vertical"));
        animator.SetBool("Jump",false);

        if (Input.GetAxis("Vertical") > 0.1f){
            animator.SetBool("Walk",true);
        }else{
            animator.SetBool("Walk",false);
        }

        switch (currentState){
            case idleState:
                if (Input.GetButtonDown("Jump")){
                    animator.SetBool("Jump",true);
                }
                break;
            case walkState:
                if (Input.GetButtonDown("Jump")){
                    animator.SetBool("Jump",true);
                }
                break;
            case walkbackState:
                if (Input.GetButtonDown("Jump")){
                    animator.SetBool("Jump",true);
                }
                break;
            default:
                break;
        }
    }
開發者ID:Coolpix,項目名稱:Unity,代碼行數:35,代碼來源:TguyControllerMio.cs


注:本文中的UnityEngine.AnimatorStateInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。