本文整理汇总了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");
}
示例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());
}
示例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);
}
}
示例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;
}
}
示例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);
}
}
示例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");
}
示例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;
}
}
}
}
示例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");
}
}
示例9: Start
// Use this for initialization
new void Start()
{
base.Start();
shipAnimator = GetComponent<Animator>();
shipAnimator.SetTrigger("Arrival");
currentHealth = maxHealth;
}
示例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;
}
示例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);
}
}
示例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");
}
示例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);
}
}
示例14: Awake
public void Awake()
{
anim = GetComponent<Animator>();
id = GetComponent<Character.CharacterIdentifier>();
Fight = GetComponent<Character.CharacterFightScript>();
anim.SetTrigger("Walk");
}
示例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;
}
}