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


C# Animator.SetTrigger方法代码示例

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


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

示例1: Start

        public void Start()
        {
            animator = GetComponent<Animator>();

            highscore = ProgressManager.GetProgress().highscores.Find(x => x.levelId == id);
            if (highscore != null && highscore.starCount > 0)
            {
                starScore = highscore.starCount;
            }
            else
            {
                starScore = 0;
            }

            Main.onSceneChange.AddListener(SceneChanged);

            Highscore.onStarChange.AddListener(HighscoreStarChanged);

            UpdateUILevel();

            if (createdByLevelswitch)
                animator.SetTrigger("levelswitch");
            else
                animator.SetTrigger("fadein");
        }
开发者ID:Badeye,项目名称:impulse,代码行数:25,代码来源:UILevel.cs

示例2: OnStateUpdate

    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        var minion = animator.gameObject.GetComponent<Minion>();
        minion.navMeshAgent.SetDestination(minion.gatheringFlag.transform.position);
        minion.navMeshAgent.Resume();

        Minion.TargetType targetType = minion.UpdateTarget();
        if (targetType == Minion.TargetType.Minion)
        {
            animator.SetTrigger("TargetMinion");
            animator.ResetTrigger("TargetConstruction");
            animator.ResetTrigger("NoTarget");
        }
        else if (targetType == Minion.TargetType.Construction)
        {
            animator.SetTrigger("TargetConstruction");
            animator.ResetTrigger("TargetMinion");
            animator.ResetTrigger("NoTarget");
        }
        else
        {
            animator.SetTrigger("NoTarget");
            animator.ResetTrigger("TargetConstruction");
            animator.ResetTrigger("TargetMinion");
        }

        animator.SetBool("Arrived", minion.HasArrived());
    }
开发者ID:MangoSister,项目名称:PinballValley,代码行数:29,代码来源:MinionFollowState.cs

示例3: ExecuteAnimation

 public static void ExecuteAnimation(Animator anim, string animationName)
 {
     // Initiates Death animation and stops other animations from play or death animation from looping
     if (animationName == "Die")
     {
         anim.SetBool(animationName, true);
         anim.SetTrigger("DieTrig");
     }
     else
     {
         anim.SetTrigger(animationName);
     }
 }
开发者ID:dulb640,项目名称:angrygoats,代码行数:13,代码来源:EnemyAnimatorController.cs

示例4: Start

 void Start()
 {
     m_Animator = GetComponent<Animator>();
     if (m_CityButtonSelection.m_ActualSelectedButton == m_Number)
     {
         m_Animator.SetTrigger("Selected");
         m_SelectedNumber = true;
     }
     else
     {
         m_Animator.SetTrigger("Unselected");
         m_SelectedNumber = false;
     }
 }
开发者ID:BaptisteBillet,项目名称:Prochain_Arret,代码行数:14,代码来源:CityButton.cs

示例5: OnStateUpdate

    // OnStateUpdate is called before OnStateUpdate is called on any state inside this state machine
    public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if(reset)
        {
            reset = false;
            death = false;
            animator.SetTrigger(t_reset);
        }
        if (stateInfo.shortNameHash == s_death)
            return;

        if(death)
        {
            animator.SetTrigger(t_death);
            return;
        }
        if (start_run)
        {
            is_run = true;
            animator.SetBool(b_run, true);
        }
        else if (end_run)
        {
            is_run = false;
            animator.SetBool(b_run, false);
        }
        start_run = end_run = false;

        if (shot)
        {
            if (stateInfo.shortNameHash == s_run)
                animator.SetBool(b_run, false);
            animator.SetTrigger(t_shot);
            shot = false;
        }
        else
        {
            if(is_run)
                animator.SetBool(b_run, true);
        }

        var transform = solider_behaviour.transform;
        if (stateInfo.shortNameHash == s_run)
        {
            //transform.Translate(transform.forward * -speed * Time.deltaTime);
            solider_behaviour.controller.SimpleMove(transform.forward.normalized * 5);
        }
    }
开发者ID:wang2124596,项目名称:Assets,代码行数:49,代码来源:SoliderAnimationBehaviour.cs

示例6: Start

	void Start()
	{
		animator = GetComponent<Animator>();
		tut = true;
		playerRgb = GetComponent<Rigidbody2D>();
		animator.SetBool("grounded",false);
		floor = GameObject.FindGameObjectWithTag("Floor");
		door = GameObject.FindGameObjectWithTag("Door");
		particle = GameObject.FindGameObjectWithTag("Particle");
		spawn = GameObject.FindGameObjectWithTag("Spawn");
		animator.SetTrigger("Lock");
		rcastDist = rcast.distance;
		if(Application.loadedLevelName == "Quantum1a")
			animator.SetTrigger("Unlock");

	}
开发者ID:aanupam3,项目名称:PIAB-Unity-master,代码行数:16,代码来源:playerController.cs

示例7: WallJump

    public void WallJump(Animator myAnimator, Rigidbody2D myRigidbody2D, WallCheck[] allWallChecks)
    {
        if(!lockWallJump)
        {
            foreach(WallCheck localWallCheck in allWallChecks)
            {
                if(localWallCheck.walled)
                {
                    lockWallJump = true;
                    if(myRigidbody2D.transform.localScale.x < 0)
                    {
                        myRigidbody2D.AddForce(new Vector2(myRigidbody2D.velocity.x + jumpForce.x, jumpForce.y));
                    }
                    else
                    {
                        myRigidbody2D.AddForce(new Vector2(myRigidbody2D.velocity.x - jumpForce.x, jumpForce.y));
                    }

                    if(!myAnimator.GetCurrentAnimatorStateInfo(0).IsName(jumpAnimationName))
                    {
                        myAnimator.SetTrigger(jumpAnimationTriggerName);
                    }
                    Invoke ("UnlockWallJump", lockTime);
                    break;
                }
            }
        }
    }
开发者ID:Dunmord,项目名称:UnityMegamanX,代码行数:28,代码来源:WallJump2D.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 )
 {
     if( Utils.Instance.GetPlayerByColor(animator.GetComponent<GameManager>().GetCurrentPlayer()).GetAnimPointMiddle() )
     {
         animator.SetTrigger("WheelFreezeTrigger");
     }
 }
开发者ID:VisualPi,项目名称:LOQUET_TIXIER_WATHTHUHEWA_Projet_Annuel,代码行数:8,代码来源:PlayerStartPointingState.cs

示例9: Start

 // Use this for initialization
 new void Start()
 {
     base.Start();
     shipAnimator = GetComponent<Animator>();
     shipAnimator.SetTrigger("Arrival");
     currentHealth = maxHealth;
 }
开发者ID:sclarke27,项目名称:LaserDefender,代码行数:8,代码来源:EnemyShip.cs

示例10: DelayedInit

		IEnumerator DelayedInit ()
		{
			yield return new WaitForSeconds (0.2f);
			moveJoystick.Init ();
			aimJoystick.Init ();
	
			moveJoystick.OnMove += UpdateMovement;
			aimJoystick.OnAim += UpdateAim;
			aimJoystick.OnMelee += DoMelee;
	
			var inputManagers = FindObjectsOfType<InputManager> ();
			inputManager = inputManagers.FirstOrDefault (j => j._isLocalPlayer);
	
			var weaponHolders = FindObjectsOfType<WeaponHolder> ();
			weaponHolder = weaponHolders.FirstOrDefault (w => w.GetId() == inputManager.ID);
	
			var statusIndicatorses = FindObjectsOfType<StatusIndicators> ();
			statusIndicators = statusIndicatorses.FirstOrDefault (s => s.transform.GetComponentInParent<NetworkIdentity> ().isLocalPlayer);
	
			animator = GetComponent<Animator> ();
			if (showTutorial)
				animator.SetTrigger ("StartTutorial");
			
			initialized = true;
	
		}
开发者ID:Kundara,项目名称:project1,代码行数:26,代码来源:Joysticks.cs

示例11: OnStateUpdate

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




        //Check Nearest Hero != Wizard
        GameObject nearestHero = GameManager.Instance.GetNearestHero(owner.transform.position);
        if (Vector3.Distance(nearestHero.transform.position, owner.transform.position) < owner.LightRadius)
        {
            if (nearestHero.GetComponent<IDamageable>().Health > 0f)
            {
                target = nearestHero.transform;
            }
        }
        else if(target.GetComponent<IDamageable>().Health <= 0f)
        {
            target = GameManager.Instance.Wizard.transform;
            owner.agent.SetDestination(target.position);
        }

        //TOATTACK

        if (owner.agent.remainingDistance <= owner.agent.stoppingDistance)
        {
            animator.SetTrigger(toAttack);
        }
        else
        {
            owner.agent.SetDestination(target.position);
        }
    }
开发者ID:SaverioDiLazzaro,项目名称:TheGGJGame,代码行数:32,代码来源:AI_Walk.cs

示例12: Start

    // ------------------------------------------------------------------------------------------
    // Use this for initialization
    //
    void Start()
    {
        animator = this.GetComponent<Animator>();

        rnd = new System.Random();
        move = rnd.Next(50,200);

        // determines new direction of movement.
        int newDir = rnd.Next(0,2333);

        // randomly determine which direction the piece's next move will be in.
        if( newDir%4 == 0 ) animator.SetTrigger("StandNorth");
        else if( newDir%4 == 1 ) animator.SetTrigger("StandEast");
        else if( newDir%4 == 2 ) animator.SetTrigger("StandSouth");
        else if( newDir%4 == 3 ) animator.SetTrigger("StandWest");
    }
开发者ID:jessupjn,项目名称:eecs494-PokemonFirstLevel,代码行数:19,代码来源:ScientistScript.cs

示例13: OnStateUpdate

 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (MoveObjectOnSphere() && Input.GetMouseButtonDown(0)) {
         spawned = true;
         animator.SetTrigger(exitTrigger);
     }
 }
开发者ID:nicolasjacquemet,项目名称:3DGeoscience,代码行数:8,代码来源:SpawnEarthquakeBehavior.cs

示例14: Awake

 public void Awake()
 {
     anim = GetComponent<Animator>();
     id = GetComponent<Character.CharacterIdentifier>();
     Fight = GetComponent<Character.CharacterFightScript>();
     anim.SetTrigger("Walk");
 }
开发者ID:ikkeboe,项目名称:SideCastle,代码行数:7,代码来源:CharacterWalk.cs

示例15: setAnimationTypeAndValue

    /// <summary>
    /// Will set the Animation with the supplied parameter
    /// </summary>
    /// <param name="animation">The Animation to set</param>
    /// <param name="animator">The animator to get the Animations</param>
    /// <param name="parameter">The value for the Animation</param>
    public static void setAnimationTypeAndValue(Animation animation, Animator animator, object value)
    {
        if(value == null) {
            return;
        }

        //Grab what Type of parameter
        AnimatorControllerParameter param = getAnimatorControllerParameter(animation, animator);

        //If param doesn't exist, just get out
        if(param == null) {
            return;
        }

        switch(param.type) {
            case AnimatorControllerParameterType.Bool:
                animator.SetBool(animation.ToString(), (bool)value);
                break;
            case AnimatorControllerParameterType.Float:
                animator.SetFloat(animation.ToString(), (float)value);
                break;
            case AnimatorControllerParameterType.Int:
                animator.SetInteger(animation.ToString(), (int)value);
                break;
            case AnimatorControllerParameterType.Trigger:
                animator.SetTrigger(animation.ToString());
                break;
            default:
                break;
        }
    }
开发者ID:JeffreyGaither,项目名称:Games,代码行数:37,代码来源:AnimationMethods.cs


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