本文整理汇总了C#中UnityEngine.AnimatorStateInfo.IsName方法的典型用法代码示例。如果您正苦于以下问题:C# AnimatorStateInfo.IsName方法的具体用法?C# AnimatorStateInfo.IsName怎么用?C# AnimatorStateInfo.IsName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.AnimatorStateInfo
的用法示例。
在下文中一共展示了AnimatorStateInfo.IsName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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" );
}
示例2: OnStateUpdate
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
base.OnStateUpdate(animator, stateInfo, layerIndex);
if (Input.GetKeyDown(KeyCode.K))
{
if (stateInfo.IsName("PowerAttack.powerattack_1") && stateInfo.normalizedTime > 0.35f)
{
animator.CrossFade("powerattack_2", 0);
}
else if (stateInfo.IsName("PowerAttack.powerattack_2") && stateInfo.normalizedTime > 0.35f)
{
animator.CrossFade("powerattack_3", 0);
}
else if (stateInfo.IsName("PowerAttack.powerattack_3") && stateInfo.normalizedTime > 0.35f)
{
animator.CrossFade("powerattack_4", 0);
}
else if (stateInfo.IsName("PowerAttack.powerattack_4") && stateInfo.normalizedTime > 0.35f)
{
animator.CrossFade("powerattack_5", 0);
}
}
}
示例3: Update
// Update is called once per frame
void Update()
{
tempo+=Time.deltaTime;
if(animator)
{
animaState = animator.GetCurrentAnimatorStateInfo(0);
if(animaState.IsName("padrao")){
if(tempo>TEMPO_DE_PISCAR )
{
piscarAgora();
}
}else if(animaState.IsName("cair")){
material.mainTextureOffset = new Vector3(3*deslocamento,0);
}else if(animaState.IsName("dano1")){
tempo = TEMPO_DE_PISCAR;
piscarAgora();
}else
material.mainTextureOffset = new Vector3(0,0);
}else
{
animator = GetComponent<Animator>();
if(animator)
animaState = animator.GetCurrentAnimatorStateInfo(0);
}
}
示例4: 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;
}
}
}
示例5: Update
void Update ()
{
currentBaseState = anim.GetCurrentAnimatorStateInfo(0);
currentShieldState = anim.GetCurrentAnimatorStateInfo(1);
// Check if size change has been activated by the user
if (character.sizeChangeTransition)
{
ActivateSizeChangeAura();
}
else if (!character.sizeChangeTransition)
{
DeativateSizeChangeAura();
}
// Check if character is holding shield
if (currentShieldState.IsName("HoldShield") || currentBaseState.IsName("Dash"))
{
ActivateShieldWave();
}
else if (!currentShieldState.IsName("HoldShield") || !currentBaseState.IsName("Dash"))
{
DeactivateShieldWave();
}
// Check if character is dashing
if (currentBaseState.IsName("Dash"))
{
ActivateDashEffect();
}
}
示例6: OnIdle
public override void OnIdle()
{
animatorController.setRuning(false);
if (inAttack)
{
// 战斗待机
}
else
{
// 处于Base Layer
// 普通待机
baseLayerStateInfo = animator.GetCurrentAnimatorStateInfo(0);
if (baseLayerStateInfo.IsName("Stand") && baseLayerStateInfo.normalizedTime > 0.9)
{
//this.animator.SetInteger("idleType", 1);
animatorController.setIdleType(1);
}
else if (baseLayerStateInfo.IsName("IDLE1") && baseLayerStateInfo.normalizedTime > 0.9)
{
//this.animator.SetInteger("idleType", 0);
animatorController.setIdleType(0);
}
}
}
示例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) {
if (stateInfo.IsName ("noop") || stateInfo.IsName ("blackout")) {
fading = false;
} else {
fading = true;
}
animator.SetBool ("fading",fading);
}
示例8: 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 (stateInfo.IsName("rotToFaceIdle") == true){
GameObject.Find("Root").GetComponent<AnimLineControl>().RunSostav();
}
if (stateInfo.IsName("idleUpCan") == true){
GameObject.Find("Root").GetComponent<AnimLineControl>().CanUpped();
}
}
示例9: 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 (stateInfo.IsName ("On")) {
}
if (stateInfo.IsName ("Off")) {
}
}
示例10: PlayerRayController
void PlayerRayController()
{
myASI = PlayerAnimator.GetCurrentAnimatorStateInfo(0);
Vector3 posPlayer;
Vector3 posPlayerDown;
posPlayer = PlayerRay.transform.position;
posPlayer.y += 1.5f;
posPlayerDown = posPlayer;
RayPlayer = new Ray (posPlayer, PlayerRay.forward);
PlayerRayDown = new Ray(posPlayerDown, -PlayerRay.up);
Debug.DrawRay(posPlayer, PlayerRay.forward * 2, Color.red);
Debug.DrawRay(posPlayerDown, -PlayerRay.up * 2, Color.green);
if (bIsGrounded && myASI.IsName("Locomotion") && !myASI.IsName("JumpUp"))
{
if (Physics.Raycast(RayPlayer, out hitInfo, 1.5f))
{
Debug.Log("Choque para subir con : " + hitInfo.transform.tag);
if (hitInfo.transform.tag.Equals("Barda") && bIsGrounded)
{
bIsGrounded = false;
PlayerAnimator.SetTrigger("JumpToWall");
}
}
}
else if (!bIsGrounded && !myASI.IsName("JumpDownRoll") && !myASI.IsName("JumpUp") && !myASI.IsName("Locomotion"))
{
if (!Physics.Raycast(PlayerRayDown, out hitInfo, 1.5f))
{
PlayerAnimator.SetTrigger("JumpDown");
bIsGrounded = true;
}
}
/// Podemos manipular los huesos para la animacion, sólo en modelos humanoides
/// y sólo para las manos y pies, en el resto de las partes del cuerpo no funcionan.
///
///Modificamos el tamaño del collider dependiendo del estado de la aninmacion
if (myASI.IsName("Dive"))
PlayerCollider.height = PlayerAnimator.GetFloat("ScaleOffsetCapsule");
else
PlayerCollider.height = startHeightCollider;
}
示例11: OnStateEnter
/// <summary>
/// Method called by unity when a state is entered
/// </summary>
/// <param name="animator">the animator where the script is called</param>
/// <param name="stateInfo">state info of the new state</param>
/// <param name="layerIndex">the layer of the state change</param>
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (stateInfo.IsName("Menu_Delete"))
{
Destroy(animator.transform.parent.gameObject);
}
}
示例12: UpdateAnimatorStates
void UpdateAnimatorStates()
{
animatorState = m_animator.GetCurrentAnimatorStateInfo(0);
if(animatorState.IsName("Base Layer.idle"))
{
if(m_animator.GetInteger("anmvlue")==0)
{
int radom=Random.Range(1,11);
if(radomValue != radom){
radomValue=radom;
m_animator.SetInteger("anmvlue",radomValue);
}
}
}
else if(m_animator.GetInteger("anmvlue")!=0)
{
if(m_animator.GetInteger("anmvlue")==10){
Voices[8].Play();
}
else{
Voices[((radomValue-1)%8)].Play();
}
m_animator.SetInteger("anmvlue",0);
}
}
示例13: Update
// Update is called once per frame
void Update () {
if (Grounded && playEff) {
playEff = false;
if (GroundEff != null)
StartCoroutine (endEff (0.85f));
}
stateInfo = anim.GetCurrentAnimatorStateInfo (0);
if (player != null && stateInfo.IsName ("idle")) {
if (player.position.x > gameObject.transform.position.x && !facingRight) {
// ... flip the player.翻轉人物(向右)讓facingRight = true
Flip ();
facingRight = true;
}else if (player.position.x < gameObject.transform.position.x && facingRight) {
// ... flip the player.翻轉人物使其向左 讓facingRight = fales
Flip ();
facingRight = false;
}
}
if (needAtk && CanAtk) {
anim.SetTrigger("Atk");
atkCooldown = Random.Range(3,atkRate);
}
//anim.SetBool ("riceGround", Grounded);
if (atkCooldown > 0) {
atkCooldown -= Time.deltaTime;
}
}
示例14: OnStateExit
void OnStateExit(AnimatorStateInfo info)
{
if (info.IsName(ExitAnimationName))
{
shouldRecycle = true;
}
}
示例15: Update
// Update is called once per frame
void Update()
{
if(PlayerAnimator == null)
PlayerAnimator = GetComponent<Animator>();
///Obtenemos el estado actual de la animacion
myASI = PlayerAnimator.GetCurrentAnimatorStateInfo(0);
///Como la tecla no tiene sensibilidad me manda 1 directamente por lo que
/// no se nota la animación de Walk y parece que pasa directo a Run
/// Con un Joystic se soluciona
///Caminamos si presionamos hacia arriba
PlayerAnimator.SetFloat("WalkForwardSpeed", Input.GetAxis("Vertical"));
///Caminamos a la Izq o Der
PlayerAnimator.SetFloat("WalkDirection", Input.GetAxis("Horizontal"));
///Preguntamos si estamos dentro de la maquina de Locomotion
/// Asi evitamos que haga otro comportamiento en cualquier otra animacion
/// en este caso evitamos que salte si no esta corriendo
if(myASI.IsName("Locomotion"))
if (Input.GetKeyDown(KeyCode.Space))
PlayerAnimator.SetTrigger("Jump");
///Saludo aplicado con mascaras
/// las máscaras sirven para desasociar partes del modelo y hacer que ciertas
/// partes haagan otras animaciones.
/// Como correr dos máquinas de estado al mismo tiempo.
/// Si por ejemplo la animacion de disparo se realiza con el avatar completamente estático
/// y quiero disparar caminando, en vez de hacer una animacion nueva de Diaparo/camino
/// lo que hago es hacer máscaras, de esa forma la parte superior del torso realiza la animacion de
/// disparo y l aparte inferior realiza la animacion de caminado.
/// De esa forma no tengo que hacer animaciones especificas para cada estado.
if (Input.GetKeyDown(KeyCode.Q))
PlayerAnimator.SetTrigger("Wave");
}