本文整理汇总了C#中UnityEngine.AnimatorStateInfo.IsTag方法的典型用法代码示例。如果您正苦于以下问题:C# AnimatorStateInfo.IsTag方法的具体用法?C# AnimatorStateInfo.IsTag怎么用?C# AnimatorStateInfo.IsTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.AnimatorStateInfo
的用法示例。
在下文中一共展示了AnimatorStateInfo.IsTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FixedUpdate
void FixedUpdate()
{
float h = Input.GetAxis("Horizontal");
//float v = Input.GetAxis("Vertical");
anim.SetFloat("Speed", h); // set our animator's float parameter 'Speed' equal to the vertical input axis
//anim.SetFloat("Direction", v); // set our animator's float parameter 'Direction' equal to the horizontal input axis
currentBaseState = anim.GetCurrentAnimatorStateInfo(0);
if(currentBaseState.IsTag("Run"))
{
if(Input.GetButtonDown("Jump"))
{
anim.SetInteger("JumpType", UnityEngine.Random.Range(0,2));
anim.SetBool("Jump", true);
}
if(Input.GetKeyDown (KeyCode.W))
{
//anim.SetInteger("JumpType", UnityEngine.Random.Range(0,3));
anim.SetBool("JumpUp", true);
}
}
else if(currentBaseState.IsTag("Jump") || currentBaseState.IsTag("Jumpup"))
{
if(!anim.IsInTransition(0))
{
anim.SetBool("Jump", false);
anim.SetBool("JumpUp", false);
}
}
}
示例2: OnStateEnter
public override void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex)
{
var fighter = animator.gameObject.GetComponent<Fighter> ();
foreach (var tag in activeTags) {
if (animatorStateInfo.IsTag(tag)) {
fighter.SoftStun = false;
return;
}
}
foreach (var tag in inactiveTags) {
if (animatorStateInfo.IsTag (tag)) {
fighter.SoftStun = true;
return;
}
}
}
示例3: OnStateExit
// OnStateUpdate is called before OnStateUpdate is called on any state inside this state machine
//override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
// OnStateExit is called before OnStateExit is called on any state inside this state machine
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if(stateInfo.IsTag("LAttackState"))
{
}
}
示例4: OnStateEnter
// OnStateEnter is called before OnStateEnter is called on any state inside this state machine
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (stateInfo.IsTag("DestroyState"))
{
animator.GetComponentInParent<BaseEnemy>().DestroyEnemy(stateInfo.length);
}
}
示例5: OnStateExit
//OnStateEnter is called before OnStateEnter is called on any state inside this state machine
//override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
// OnStateUpdate is called before OnStateUpdate is called on any state inside this state machine
//override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
// OnStateExit is called before OnStateExit is called on any state inside this state machine
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (stateInfo.IsTag ("Transition")) {
animator.SetBool ("Done", true);
} else {
animator.SetBool ("Done", false);
}
}
示例6: OnStateExit
// 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)
{
animator.GetComponent<Character>().Attack = false;
if (stateInfo.IsTag("attack")) {
animator.GetComponent<Character>().MeleeAttack();
}
animator.ResetTrigger("attack");
animator.ResetTrigger("throw");
}
示例7: Update
protected virtual void Update()
{
current_stateInfo = mAnimator.GetCurrentAnimatorStateInfo(0);
//受伤
if (current_stateInfo.IsTag("Damage"))
{
mAnimator.SetBool("Damage", false);
SetAttackMove(AttackMove_Speed);
}
}
示例8: Update
void Update()
{
state = animator.GetCurrentAnimatorStateInfo(0);
if (state.IsTag("Jump"))
{
if (animator.GetFloat("Height") > 0.5f && animator.GetBool("AttackKeyDown"))
{
animator.SetInteger("ActionCMD", 1);
}
}
}
示例9: OnStateExit
// OnStateEnter is called before OnStateEnter is called on any state inside this state machine
//override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
// OnStateUpdate is called before OnStateUpdate is called on any state inside this state machine
//override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
//
//}
// OnStateExit is called before OnStateExit is called on any state inside this state machine
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (stateInfo.IsTag("Attack"))
{
animator.SendMessageUpwards("AttackAnimationComplete", SendMessageOptions.DontRequireReceiver);
}
else if (stateInfo.IsTag("LongAttack"))
{
animator.SendMessageUpwards("LongAttackAnimationComplete", SendMessageOptions.DontRequireReceiver);
}
else if (stateInfo.IsTag("ConeAttack"))
{
animator.SendMessageUpwards("ConeAttackAnimationComplete", SendMessageOptions.DontRequireReceiver);
}
else if (stateInfo.IsTag("Bite"))
{
animator.SendMessageUpwards("BiteAnimationComplete", SendMessageOptions.DontRequireReceiver);
}
else if (stateInfo.IsTag("SwingOpen"))
{
Debug.Log("upwards " + animator);
animator.SendMessageUpwards("SwingOpenAnimationComplete", SendMessageOptions.DontRequireReceiver);
}
else if (stateInfo.IsTag("SwingClose"))
{
Debug.Log("upwards " + animator);
animator.SendMessageUpwards("SwingCloseAnimationComplete", SendMessageOptions.DontRequireReceiver);
}
}
示例10: OnStateEnter
public new void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (stateInfo.IsTag("held"))
{
if (!this.playerEvents)
{
this.playerEvents = animator.transform.GetComponent<animEventsManager>();
}
if (this.playerEvents)
{
this.playerEvents.enableSpine();
}
}
}
示例11: Update
void Update ()
{
foreach (AnimEvent animEvent in Events) {
stateInfo = animator.GetCurrentAnimatorStateInfo (animEvent.layer);
if (stateInfo.IsTag (animEvent.animationTag)) {
if (stateInfo.normalizedTime >= animEvent.fireTime) {
if (animEvent.eventType == AE_EventType.Instantiate)
CreateInstance (animEvent);
else if (animEvent.eventType == AE_EventType.FireMethod)
FireMethod (animEvent);
}
} else animEvent.Reset ();
}
}
示例12: Update
// Update is called once per frame
void Update()
{
_info = _anim.GetCurrentAnimatorStateInfo(0); //what animation is playing?
//////////////////////MOVEMENT//////////////////////
float _x, _y, _r; // local variables get deleted at the function's end
_x = Input.GetAxis("Horizontal"); // the horizontal axis (1 or -1)
_y = Input.GetAxis("Vertical"); // the vertical axis
_r = Input.GetAxis("Rotate"); // the rotation axis
Vector3 moveDir = new Vector3 (_x, 0, _y)*(moveSpeed*Time.deltaTime); // the inputs multiplying the movement speed (1 * 30 or -1 * 30)
moveDir.y = gravity*Time.deltaTime; //apply gravity
moveDir = transform.TransformDirection (moveDir); //MY direction not the world direction
_char.Move (moveDir); //apply movement
float _curRot = transform.eulerAngles.y; //my y rotation
float _wantRot = _curRot += ((rotSpeed * Time.deltaTime) * _r); //apply rotation to new var
transform.rotation = Quaternion.Euler(0f,_wantRot, 0f); //rotation
_anim.SetFloat ("Y", _y);//send the inputs to animator
_anim.SetFloat ("X", _x);
//////////////////////COMBAT//////////////////////
if (!_info.IsTag ("InAttack")) { //am i not attacking?
if(AttFlag != 0) //I'm not, but I have a flag remaining?
{
AttFlag=0; //remove the flag ready for the next attack
_anim.SetInteger("AttackIdx", AttFlag);
}
}
if (Input.GetButtonDown ("Fire1")) { //player has asked to attack
_anim.SetBool("Down1", true);
if(AttFlag == 0) //am I ready to attack?
{
AttFlag=1; //send the flag to the animator
_anim.SetInteger("AttackIdx", AttFlag);
}
}
if (Input.GetButtonUp ("Fire1")) { //player has released the mouse btn
_anim.SetBool("Down1", false);
}
}
示例13: Update
// Update is called once per frame
void Update()
{
distanceToPlayer = Vector2.Distance(this.transform.position, playerRef.transform.position);
aiAnimatorState = aiAnimator.GetCurrentAnimatorStateInfo (0);
//if((distanceToPlayer>distanceToAttack) )
switch(aiBehaviour)
{
case AIBehaviour.ATTACK:
if( (!GameGlobalVariablesManager.isBombActivated)&& !aiAnimatorState.IsTag (("DeathTag")))// && !GameGlobalVariablesManager.isKnifeThrow )
MoveTowardsPlayer ();
break;
case AIBehaviour.RANGED:
if( (!GameGlobalVariablesManager.isBombActivated)&& !aiAnimatorState.IsTag (("DeathTag") ))//&& !GameGlobalVariablesManager.isKnifeThrow )
MoveTowardsPlayerToThrow ();
break;
}
if (GameGlobalVariablesManager.isBombActivated)
{
canStun = true;
bTimer -= Time.deltaTime;
Stun ();
}
/*
if(Input.GetMouseButtonDown(1))
{
React();
}*/
}
示例14: Update
void Update()
{
// Save the state in playing now.
// 再生中のステートの情報を入れる。.
// 재생중인 스테이트를 저장.
stateInfo = chrAnimator.GetCurrentAnimatorStateInfo(0);
// Bool parameter reset to false.
if(!stateInfo.IsTag("InIdle")){
chrAnimator.SetBool("LookAround", false);
chrAnimator.SetBool("Attack", false);
chrAnimator.SetBool("Jiggle", false);
chrAnimator.SetBool("Dead", false);
}
// reaction of key input.
// キー入力に対するリアクションを起こす。.
// 키입력에 대한 반응.
// for Attack
if(Input.GetButtonDown("Fire1")) chrAnimator.SetBool("Attack", true);
// LookAround
if(Input.GetKeyDown("z")) chrAnimator.SetBool("LookAround", true);
// Jiggle
if(Input.GetKeyDown("x")) chrAnimator.SetBool("Jiggle", true);
// Happy!!
if(Input.GetKeyDown("c"))
{
chrAnimator.SetBool("Happy", !chrAnimator.GetBool("Happy"));
if(chrAnimator.GetBool("Happy") == true) chrAnimator.SetBool("Sad", false);
}
// Sad
if(Input.GetKeyDown("v"))
{
chrAnimator.SetBool("Sad", !chrAnimator.GetBool("Sad"));
if(chrAnimator.GetBool("Sad") == true) chrAnimator.SetBool("Happy", false);
}
// for Dead
if(Input.GetKeyDown("b")) chrAnimator.SetBool("Dead", true );
// movement.
// Input of character moves
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
Vector3 axisInput = new Vector3(h, 0, v);
float axisInputMag = axisInput.magnitude;
if(axisInputMag > 1){
axisInputMag = 1;
axisInput.Normalize();
}
runParam = 0f;
if(axisInputMag != 0){
// for run
if(Input.GetButton("Fire2")){
runParam = 1.0f;
}
// character rotate
axisInput = Camera.main.transform.rotation * axisInput;
axisInput.y = 0;
transform.forward = axisInput;
}
chrAnimator.SetFloat("Speed", (axisInputMag + runParam));
// Jump
// while in jump, I am using Character Controller instead Root Motion, to move the Character.
// ジャンプ時は、キャラクターコントローラを使ってキャラクターを移動させます。.
// 점프시에는 캐릭터 컨트롤러를 이용하여 캐릭터를 이동시키고 있습니다.
// in ground.
if(chrController.isGrounded){
// jump parameter set to false.
chrAnimator.SetInteger("Jump", 0);
// moveDirection set 0, to prevent to move by Character controller.
// moveDirectionはゼロにして、キャラクターコントローラがキャラクターを動かさないように。.
// moveDirection은 0으로 돌려서, 캐릭터 컨트롤러가 캐릭터를 움직이지 않도록한다.
moveDirection = new Vector3(0, jumpInput, 0);
// press Jump button. make jump
// if Animator parameter "Jump" is true,
// animator will play state of "na_Jump_00" and "na_Jump_00_up"
// then animation event of "na_Jump_00_up" will call SetJump()
// Jumpパラメータからアニメーションが遷移し、.
// "na_Jump_00_up"のときにイベントでSetJump()ファンクションを呼ぶ。.
// Jump파라메터를 통해 스테이트가 점프애니메이션을 재생하고,
// "na_Jump_00_up"스테이트를 재생할때 SetJump()를 부른다.
if(Input.GetButtonDown("Jump"))
SetJump ();
}
// While in Air
else if(!chrController.isGrounded){
// press Jump button. can jump once more.
if(Input.GetButtonDown("Jump"))
SetJump ();
// It is moved with Character Controller while in the air,
// moveDirection is use Axis Input.
// 空中にいるときはmoveDirectionを使って移動するので、.
// 方向キーの入力を渡しておく。.
// 공중에 있는 동안은 캐릭터 컨트롤러를 사용하여 이동하기때문에.
// 방향키의 입력을 moveDirection에게 전달해준다.
moveDirection = new Vector3(transform.forward.x * axisInputMag * 4, moveDirection.y, transform.forward.z * axisInputMag * 4);
//.........这里部分代码省略.........
示例15: _Combat
//=================================================================================================================o
//===============================================Combat============================================================o
//=================================================================================================================o
void _Combat()
{
// Combat Stance / Out
if (doCombat && canDrawHolster)
{
// Coroutine draw motion finished -> switch
if (weaponState == WeaponState.None)
{
return;
}
/*else if(weaponState == WeaponState.Unarmed)
{
return;
}*/
else if (weaponState == WeaponState.Sword)
{
StartCoroutine(DrawHolster(0.3f, weapons.sword_Holster.GetComponent<Renderer>(), weapons.sword_Hand.GetComponent<Renderer>()));
animator.SetBool("Sword", false);
baseState = BaseState.Base;
}
else if (weaponState == WeaponState.Bow)
{
StartCoroutine(DrawHolster(0.6f, weapons.bow_Holster.GetComponent<Renderer>(), weapons.bow_Hand.GetComponent<Renderer>()));
animator.SetBool("Bow", false);
baseState = BaseState.Base;
}
else if (weaponState == WeaponState.Rifle)
{
StartCoroutine(DrawHolster(0.9f, weapons.rifle_Holster.GetComponent<Renderer>(), weapons.rifle_Hand.GetComponent<Renderer>()));
animator.SetBool("Rifle", false);
baseState = BaseState.Base;
}
else if (weaponState == WeaponState.Pistol)
{
StartCoroutine(DrawHolster(0.6f, weapons.pistol_Holster.GetComponent<Renderer>(), weapons.pistol_Hand.GetComponent<Renderer>()));
animator.SetBool("Pistol", false);
baseState = BaseState.Base;
}
}
// Double Tap - Evade takes tapSpeed & coolDown in seconds
if (canEvade)
{
if (!isDoubleTap) StartCoroutine(DoubleTap(doubleTapSpeed, 1));
}
// Current state info for layer Base
animatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
if (grounded)
{
if (doJumpDown /*&& canJump */&& !animatorStateInfo.IsTag("Jump") && !animatorStateInfo.IsTag("Land"))
{
animator.SetBool("Jump", true);
//add extra force to main jump
rigidbody.velocity = hero.up * jumpHeight;
// Start cooldown until we can jump again
//StartCoroutine (JumpCoolDown(0.5f));
}
// Don't slide
if (!rigidbody.isKinematic)
rigidbody.velocity = new Vector3(0, rigidbody.velocity.y, 0);
// Extra rotation
if (canRotate)
{
if (!doLShift)
hero.Rotate(0, mX * rotSpeed / 2 * Time.deltaTime, 0);
}
// Punch, Kick
if (doAtk1Down && !animatorStateInfo.IsTag("Attack1"))
{
animator.SetBool("Attack1", true);
animator.SetBool("Walking", false); // RESET
animator.SetBool("Sprinting", false); // RESET
animator.SetBool("Sneaking", false); // RESET
}
else if (doAtk2Down && !animatorStateInfo.IsTag("Attack2"))
{
animator.SetBool("Attack2", true);
animator.SetBool("Walking", false); // RESET
animator.SetBool("Sprinting", false); // RESET
animator.SetBool("Sneaking", false); // RESET
}
// Walk
if (doWalk)
{
if (!animatorStateInfo.IsTag("WalkTree"))//IsName("WalkTree.TreeW"))
{
animator.SetBool("Walking", true);
animator.SetBool("Sneaking", false); // RESET
animator.SetBool("Sprinting", false); // RESET
}
//.........这里部分代码省略.........