本文整理汇总了C#中UnityEngine.Animator.IsInTransition方法的典型用法代码示例。如果您正苦于以下问题:C# Animator.IsInTransition方法的具体用法?C# Animator.IsInTransition怎么用?C# Animator.IsInTransition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Animator
的用法示例。
在下文中一共展示了Animator.IsInTransition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStateUpdate
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
//This is where combatanimation gets turned of after played wanted amount of time.
//Portrett is player animation
if (animator.name == "Portrett")
{
if (stateInfo.normalizedTime > 1 && !animator.IsInTransition (layerIndex))
{
if (animator.GetBool ("isHappyMainCharacter") == true)
{
animator.SetBool ("isHappyMainCharacter", false);//Length 2 sec
}
if (animator.GetBool ("isAngryMainCharacter") == true)
{
animator.SetBool ("isAngryMainCharacter", false);//Length 2.45 sec
}
}
}
//This is boss animation
else if (animator.name == "Portrett2_boss")
{
if (stateInfo.normalizedTime > 2 && !animator.IsInTransition (layerIndex))
{
if (animator.GetBool ("isHappyBoss") == true)
{
animator.SetBool ("isHappyBoss", false);//Length 1 sec
}
if (animator.GetBool ("isAngryBoss") == true)
{
animator.SetBool ("isAngryBoss", false);//Length 1.2 sec
}
}
}
//This is enemy animation
else if (animator.name == "Portrett2_marine")
{
if (stateInfo.normalizedTime > 2 && !animator.IsInTransition (layerIndex))
{
if (animator.GetBool ("isHappyMarine") == true)
{
animator.SetBool ("isHappyMarine", false);//Length 1.2 sec
}
if (animator.GetBool ("isAngryMarine") == true)
{
animator.SetBool ("isAngryMarine", false);//Length 1.2 sec
}
}
}
}
示例2: startWalking
//prepare the animal to start walking animation
//param: anim - animator of the animal
protected void startWalking(Animator anim) {
if (anim.IsInTransition(0) && bStartMoving) {
bMoving = true;
bStartMoving = false;
transform.rotation = Quaternion.LookRotation(moveVector) * transform.rotation;
}
}
示例3: ConditionToChangeOn
protected override bool ConditionToChangeOn(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (animator.GetBool(GroundVariableName) && !animator.IsInTransition(layerIndex)) {
return ChangeOnGround;
} else {
return ChangeOnAir;
}
}
示例4: OnStateUpdate
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (animator.IsInTransition(0))
return;
_player.FacingDirectionUpdate();
if (_player.isArrived)
_animator.SetBool("Run", false);
}
示例5: WaitForAnimation
private IEnumerator WaitForAnimation(Animator animator)
{
do
{
yield return null;
} while (animator.GetCurrentAnimatorStateInfo(0).IsName("Armature|Victory") || animator.GetCurrentAnimatorStateInfo(0).IsName("Armature|Victory0") || animator.IsInTransition(0));
laser.SetActive(true);
}
示例6: OnStateUpdate
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (animator.IsInTransition(0))
return;
_enemy.FacingDirectionUpdate();
if (_enemy.mainTarget)
_nma.destination = _enemy.mainTarget.transform.position;
else
animator.SetBool("Chase", false);
}
示例7: 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 (stateInfo.normalizedTime > 1 && !animator.IsInTransition(layerIndex)) {
_counterWaitingTime += Time.deltaTime;
if (_counterWaitingTime >= WaitingTime) {
Application.LoadLevel(Application.loadedLevel);
}
}
}
示例8: 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 (stateInfo.normalizedTime > WhenDestroy && !animator.IsInTransition(layerIndex)) {
if (DependsOnSpeed) {
if (animator.GetFloat(SpeedVariableName) == Speed) {
Destroy(animator.gameObject);
}
} else {
Destroy(animator.gameObject);
}
}
}
示例9: DisablePanelDeleyed
IEnumerator DisablePanelDeleyed (Animator anim)
{
bool closedStateReached = false;
bool wantToClose = true;
while (!closedStateReached && wantToClose) {
if (!anim.IsInTransition (0))
closedStateReached = anim.GetCurrentAnimatorStateInfo (0).IsName ("Closed");
wantToClose = !anim.GetBool (m_OpenParameterId);
yield return new WaitForEndOfFrame ();
}
if (wantToClose)
anim.gameObject.SetActive (false);
}
示例10: OnStateUpdate
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (stateInfo.normalizedTime > WhenApplyDelay && !animator.IsInTransition(layerIndex)) {
if (_counterTimeTillResume >= TimeTillResume) {
_actualSpeed += SpeedAugmentedFactor;
} else {
_counterTimeTillResume += Time.deltaTime;
_actualSpeed -= SpeedDecreaseFactor;
}
_actualSpeed = Mathf.Clamp(_actualSpeed, DelaySpeedValue, ResumeSpeedValue);
animator.SetFloat(SpeedVariableName, _actualSpeed);
}
}
示例11: OnStateUpdate
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
frameCount++;
Debug.Log(frameCount);
if (stateInfo.normalizedTime > 1 && !animator.IsInTransition(0))
{
switch (boolToStop)
{
case BooltoStop.Dive: PlayerData.Instance.canDive = false; break;
case BooltoStop.Ninja: PlayerData.Instance.canNinja = false; break;
case BooltoStop.Punch: PlayerData.Instance.canPunch = false; break;
}
}
if (frameCount >= 30 && !shot && projectile != null)
{
GameObject go = Instantiate(projectile) as GameObject;
go.transform.rotation = animator.transform.rotation;
go.transform.position = animator.transform.position + animator.transform.up * 1 + animator.transform.forward * 1;
shot = true;
}
}
示例12: WaitForAnimatorFinish
public static IEnumerator WaitForAnimatorFinish(Animator animator, int layer)
{
while( true ) {
yield return null;
if( animator.IsInTransition(layer) )
continue;
AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(layer);
Debug.Log("state info name is attack ? " + stateInfo.IsName("Attack"));
Debug.Log("state info name is attack done ? " + stateInfo.IsName("Attack Done"));
Debug.Log("state info name is idle ? " + stateInfo.IsName("Idle"));
Debug.Log("animate state info = " + stateInfo.normalizedTime);
if( stateInfo.normalizedTime >= 1 )
break;
}
}
示例13: DisablePanelDeleyed
private IEnumerator DisablePanelDeleyed(Animator anim)
{
bool closedStateReached = false; // Closed 상태로 완전히 전이되었는가?
bool wantToClose = true; // 코루틴 도중에 anim 값바뀜 체크?
while (!closedStateReached && wantToClose)
{
if (!anim.IsInTransition(0))
{
closedStateReached = anim.GetCurrentAnimatorStateInfo(0).IsName(_closedStateName);
}
wantToClose = !anim.GetBool(_openParameterId);
yield return new WaitForEndOfFrame();
}
if (wantToClose)
{
anim.gameObject.SetActive(false);
}
}
示例14: OnStateUpdate
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (_BehaviourState == AnimationBehaviourState.INITIAL_POSE)
{
if (!animator.IsInTransition(0))
animator.speed = 0;
return;
}
const float INTERVAL = 0.1f;
if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
{
timeSinceCapture += Time.deltaTime;
/*
if (timeSinceCapture > INTERVAL)
{
timeSinceCapture = timeSinceCapture - INTERVAL;
if (exerciseDataGenerator == null)
exerciseDataGenerator = GameObject.FindObjectOfType<Detector.ExerciseDataGenerator>();
if (this.exerciseDataGenerator != null)
this.exerciseDataGenerator.CaptureData();
}*/
}
DateTime temp = DateTime.Now;
if ((_BehaviourState != AnimationBehaviourState.STOPPED && _BehaviourState != AnimationBehaviourState.RUNNING_DEFAULT)
&& (endRepTime == null || new TimeSpan(0, 0, (int)_RealParams.SecondsBetweenRepetitions) <= temp - endRepTime))
{
if (!BeginRep && (!IsInterleaved || (IsInterleaved && limb == Limb.Left)) &&
this._BehaviourState != AnimationBehaviourState.PREPARING_WEB &&
this._BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS &&
this._BehaviourState != AnimationBehaviourState.PREPARING_DEFAULT)
{
OnRepetitionReallyStart();
BeginRep = true;
}
if (stateInfo.normalizedTime >= 1.0f && haCambiadoDeEstado)
{
BeginRep = false;
if (this._behaviourState == AnimationBehaviourState.RUNNING_WITH_PARAMS)
{
OnLerpRoundTripEnd();
if (!IsInterleaved || (IsInterleaved && limb == Limb.Right))
{
if ((!this.IsWeb) && (!this.IsInInstruction) && (!this.IsInInstruction))
{
this.PauseAnimation();
}
// importante: el orden de llamadas es esencial para el correcto funcionamiento
OnRepetitionEnd();
}
if (IsInterleaved)
{
haCambiadoDeEstado = false;
animator.SetTrigger("ChangeLimb");
}
if(!IsInterleaved && (this.IsWeb || this.IsInInstruction) )
{
animator.Play(animator.GetCurrentAnimatorStateInfo(0).fullPathHash, 0, 0);
}
if (this._BehaviourState == AnimationBehaviourState.STOPPED)
{
endRepTime = null;
}
}
else if (this._behaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
{
OnRepetitionEnd();
Stop();
}
}
else
{
if (this._BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS || this._behaviourState == AnimationBehaviourState.RUNNING_WITH_PARAMS)
{
if (stateInfo.normalizedTime <= 0.5f)
{
animator.speed = this._RealParams.ForwardSpeed;
}
else
{
animator.speed = this._RealParams.BackwardSpeed;
}
}
}
}
}
示例15: DisablePanelDeleyed
private void DisablePanelDeleyed(Animator anim)
{
bool closedStateReached = false;
bool wantToClose = true;
if (!closedStateReached && wantToClose)
{
if (!anim.IsInTransition(0))
closedStateReached = anim.GetCurrentAnimatorStateInfo(0).IsName(k_ClosedStateName);
wantToClose = !anim.GetBool(m_OpenParameterId);
}
if (wantToClose)
anim.gameObject.SetActive(false);
}