本文整理匯總了C#中Animator.CrossFade方法的典型用法代碼示例。如果您正苦於以下問題:C# Animator.CrossFade方法的具體用法?C# Animator.CrossFade怎麽用?C# Animator.CrossFade使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Animator
的用法示例。
在下文中一共展示了Animator.CrossFade方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: 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);
}
}
}
示例2: Awake
void Awake(){
audio = this.gameObject.AddComponent<AudioSource>();
audio.playOnAwake = false;
audio.loop = false;
my_transform = this.gameObject.GetComponent<Transform> ();
move_enemy = my_transform.Find ("ob");
if(move_enemy == null){
Debug.Log("move_enemy is null");
}
player = move_enemy.Find("fast_move_enemy").gameObject.GetComponent<Animator>();
up_check = my_transform.Find ("up_check");
down_check = my_transform.Find ("down_check");
left_check = my_transform.Find ("left_check");
right_check = my_transform.Find ("right_check");
if (stand_direction == 1) {
player.CrossFade ("stand", 0);
} else if (stand_direction == 2) {
player.CrossFade ("down",0);
}else if (stand_direction == 3) {
player.CrossFade ("left_stand",0);
}else if (stand_direction == 4) {
player.CrossFade ("right_stand",0);
}
}
示例3: Awake
void Awake(){
audio = this.gameObject.AddComponent<AudioSource>();
audio.playOnAwake = false;
audio.loop = false;
my_transform = this.gameObject.GetComponent<Transform> ();
move_enemy = my_transform.Find ("ob");
player = move_enemy.Find("attact_enemy").gameObject.GetComponent<Animator>();
bar = this.gameObject.transform.Find("barrel").GetComponent<BoxCollider2D>();
if (stand_direction == 1) {
player.CrossFade ("stand_", 0);
} else if (stand_direction == 2) {
player.CrossFade ("down",0);
}else if (stand_direction == 3) {
player.CrossFade ("left_stand",0);
}else if (stand_direction == 4) {
player.CrossFade ("right_stand",0);
}
}
示例4: OnStateExit
// 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
//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)
{
var currentDirection = (Direction)animator.GetInteger("FaceDirection");
if (animator.GetBool("MeleeAttackBool"))
{
animator.SetBool("MeleeAttackBool", false);
switch (currentDirection)
{
case Direction.Up:
animator.CrossFade("P_Idle_Up", 0.5f);
break;
case Direction.Down:
animator.CrossFade("P_Idle_Down", 0.5f);
break;
case Direction.Left:
animator.CrossFade("P_Idle_Left", 0.5f);
break;
case Direction.Right:
animator.CrossFade("P_Idle_Right", 0.5f);
break;
}
}
ResetAnimationState(animator);
}
示例5: Awake
void Awake(){
audio = this.gameObject.AddComponent<AudioSource>();
audio.playOnAwake = false;
audio.loop = false;
my_transform = this.gameObject.GetComponent<Transform> ();
normal_enymy = my_transform.Find ("normal_enymy");
player = my_transform.Find ("normal_enymy").gameObject.GetComponent<Animator> ();
up_check = my_transform.Find ("up_check");
down_check = my_transform.Find ("down_check");
left_check = my_transform.Find ("left_check");
right_check = my_transform.Find ("right_check");
if (stand_direction == 1) {
player.CrossFade ("stand_", 0);
} else if (stand_direction == 2) {
player.CrossFade ("down",0);
}else if (stand_direction == 3) {
player.CrossFade ("left_stand",0);
}else if (stand_direction == 4) {
player.CrossFade ("right_stand",0);
}
compress ();
}
示例6: Awake
void Awake(){
audio = this.gameObject.AddComponent<AudioSource>();
AudioClip clip = Resources.Load<AudioClip>("sound/trap");
audio.playOnAwake = false;
audio.loop = false;
audio.clip = clip;
change_times = g_d_m.chang_number;
player = this.gameObject.GetComponent<Animator> ();
if (direction == 1) {
player.CrossFade ("left_idle",0f);
} else {
player.CrossFade ("right_idle",0f);
}
}
示例7: ResetAnimationState
public void ResetAnimationState(Animator animator)
{
var currentDirection = (Direction)animator.GetInteger("FaceDirection");
switch (currentDirection)
{
case Direction.Up:
animator.CrossFade("P_Idle_Up", 0.5f);
break;
case Direction.Down:
animator.CrossFade("P_Idle_Down", 0.5f);
break;
case Direction.Left:
animator.CrossFade("P_Idle_Left", 0.5f);
break;
case Direction.Right:
animator.CrossFade("P_Idle_Right", 0.5f);
break;
}
}
示例8: Start
// Use this for initialization
void Start()
{
controle = GetComponent<CharacterController> ();
alturaAtual = transform.position.y;
alturaDoDano = alturaAtual;
posicaoInicial = transform.position;
transform.rotation = Quaternion.LookRotation (-direcaoDoDano);
cancelaAcao();
animator = GetComponent<Animator>();
if(vivo)
animator.CrossFade("dano1",0);
}
示例9: Start
void Start ()
{
AI.GetComponent<EnemyController> ().enemyState = EnemyController.EnemyState.Walking;
anim = GetComponent<Animator> ();
anim.CrossFade ("Walking", 0.1f);
alreadyRoom = new List<string> ();
isChangingRoom = false;
alreadyChangeRoom = false;
isFromRoomToHall = false;
//<Viên>
Direction = 1;
//<Lâm>
//StartCoroutine (whatWayToGo (0.2f));
}
示例10: FixedUpdate
//.........這裏部分代碼省略.........
movementSpeed = 0;
}
}
//pulling up over a ledge
ClimbingOverLedge();
//when scripts are being enabled or disabled, warn the user if any script names they entered do not exist on the player
ScriptWarning();
//making sure player is not stuck on a collider
CheckIfStuck();
//animations
if (GetComponent<Animator>())
{
animator = GetComponent<Animator>();
//animating grabbing back on to a ledge after walking off
if (turnBack && !turnedBackToLedge && walkingOffLedgeDetectors.allowGrabbingBackOnToLedges && nonJumpTurnAround)
{
//if the angle between the player and wall we are grabbing back on to is less than 90, turn to the left
if (angleBetweenPlayerAndTurnBackWall < 90)
{
animator.SetFloat("ledgeState", 1);
}
//if the angle between the player and wall we are grabbing back on to is greater than or equal to 90, turn to the right
else
{
animator.SetFloat("ledgeState", 2);
}
animator.CrossFade("LedgeMovement", 0f, -1, 0f);
turnedBackToLedge = true;
}
else if (!turnBack && !back2 && turnedBackToLedge && Input.GetAxis("Horizontal") != 0)
{
turnedBackToLedge = false;
}
if (switching)
{
animator.speed = (ledgeSwitchingDetectors.switchJumpSpeed / switchPointDist * 3) / 4;
}
if (grabbedOn && !turnedBackToLedge)
{
if (!animator.GetBool("onLedge"))
{
animator.SetBool("onLedge", true);
}
if (!switchJumping)
{
animator.SetFloat("ledgeAngle", ledgeAngle);
if (Input.GetAxis("Horizontal") > 0 && movingDetectors.moveSpeed > 0)
{
animator.speed = ((movingDetectors.moveSpeed / 3) / movingDetectors.burstLength) / ((movingDetectors.moveSpeed * 2) / (3 + movingDetectors.moveSpeed));
//animating moving to the right while grabbed on to a ledge
if (!switching)
{
if (right && !stuckToRight)
示例11: Start
public void Start()
{
_guiCanvas = GuiCanvas.Instance;
_talkingUi = _guiCanvas.TalkingUi;
_animator = GetComponentInChildren<Animator>();
_birdProps = BirdPropsService.Instance.GetBirdPropsById(TextId);
if (_birdProps != null)
{
if (_birdProps.AnimatorController != null)
{
_animator.runtimeAnimatorController = _birdProps.AnimatorController;
}
_animator.CrossFade(_birdProps.DefaultAnim, 0f);
}
else
{
_birdProps = new BirdProps("Idle", true, null);
}
QMark = transform.FindChild("?").gameObject;
QMark.SetActive(false);
Directions = DirectionService.Instance.GetDirectionsById(TextId);
_animator.CrossFade(_birdProps.DefaultAnim, 0f);
_animator.transform.localScale =
_animator.transform.localScale.SetX(_birdProps.FaceLeft ? 1 : -1);
if (State.Instance.LevelEntrance == LevelEntrance.BeachRival && TextId == "Rival")
{
var lossDialog = new List<Direction>
{
new Line("Winson \"Collecto\"", "Woof. Erm, Chirp. Not the best dancing I've seen."),
new Line("Winson \"Collecto\"", "We can go again any time. You may need to practice.")
};
var perfectDialog = new List<Direction>
{
new Line("Winson \"Collecto\"", "Wow. Just wow. I am very impressed."),
new Line("Winson \"Collecto\"", "So, about your prize. It's the most prized and valuable thing to my name."),
new Line("Winson \"Collecto\"", "It's... my respect. You have my respect. Good job guy."),
new Line("Winson \"Collecto\"", "We can go again any time.")
};
var okDialog = new List<Direction>
{
new Line("Winson \"Collecto\"", "Pretty good. Not perfect, but pretty good."),
new Line("Winson \"Collecto\"", "You're an ok bird."),
new Line("Winson \"Collecto\"", "We can go again any time, if you'd like.")
};
Directions = new List<Direction>
{
new Line("Winson \"Collecto\"", "Wow. Just wow. I am very impressed."),
new Line("Winson \"Collecto\"", "So, about your prize. It's the most prized and valuable thing to my name."),
new Line("Winson \"Collecto\"", "It's... my respect. You have my respect. Good job guy."),
new Line("Winson \"Collecto\"", "We can go again any time.")
};
if (State.Instance.FailedBeats <= 5
&& State.Instance.FailedBeats > 2)
{
Directions = okDialog;
}
else if (State.Instance.FailedBeats <= 2)
{
Directions = perfectDialog;
}
else
{
Directions = lossDialog;
}
_animator.CrossFade("Talk", 0f);
StartCoroutine(StartSequence(() =>
{
Directions = DirectionService.Instance.GetDirectionsById(TextId);
FindObjectOfType<Control>().Disabled = false;
_animator.CrossFade("Idle", 0f);
}));
}
}
示例12: FastForwardAnimator
void FastForwardAnimator(Animator animator, float second, float crossfade)
{
for (var layer = 0; layer < animator.layerCount; layer++)
{
var info = animator.GetCurrentAnimatorStateInfo(layer);
if (crossfade > 0.0f)
animator.CrossFade(info.nameHash, crossfade / info.length, layer, info.normalizedTime + second / info.length);
else
animator.Play(info.nameHash, layer, info.normalizedTime + second / info.length);
}
}
示例13: testeDeVida
void testeDeVida(Transform Y,Animator Z)
{
float W = Y.GetComponent<umCriature> ().criature ().cAtributos [0].Corrente;
if(W<=0)
{
Z.CrossFade("cair",0);
}
}
示例14: Start
void Start()
{
animator = GetComponent<Animator>();
eventSystem = GameObject.Find("EventSystem").GetComponent<EventSystem>();
continueButton = GameObject.Find("Panel/Main/ContinueButton").GetComponent<Button>();
continueButton.onClick.AddListener(ContinueGame);
newGameButton = GameObject.Find("Panel/Main/NewGameButton").GetComponent<Button>();
newGameButton.onClick.AddListener(NewGame);
optionsButton = GameObject.Find("Panel/Main/OptionsButton").GetComponent<Button>();
optionsButton.onClick.AddListener(EnterOptions);
exitButton = GameObject.Find("Panel/Main/ExitButton").GetComponent<Button>();
exitButton.onClick.AddListener(Exit);
backButton = GameObject.Find("Panel/Options/BackButton").GetComponent<Button>();
backButton.onClick.AddListener(LeaveOptions);
yesButton = GameObject.Find("Panel/Override/YesButton").GetComponent<Button>();
yesButton.onClick.AddListener(ConfirmOverride);
noButton = GameObject.Find("Panel/Override/NoButton").GetComponent<Button>();
noButton.onClick.AddListener(CancelOverride);
musicVolumeSlider = GameObject.Find("Panel/Options/MusicSlider").GetComponent<Slider>();
musicVolumeSlider.onValueChanged.AddListener(Utils.ChangeMusicVolume);
sfxVolumeSlider = GameObject.Find("Panel/Options/SFXSlider").GetComponent<Slider>();
sfxVolumeSlider.onValueChanged.AddListener(Utils.ChangeSfxVolume);
granny = GameObject.Find("Granny").GetComponent<PlayerController>();
PlayerController.IsAttacking = false; //quick fix
levelEntries = GameObject.FindObjectsOfType<LevelEntry>();
if (GameProgress.Instance.Level == 0)
{
continueButton.interactable = false;
}
if (ShowLevelSelection)
{
animator.SetBool("LevelSelect", true);
animator.CrossFade("MainLevelSelect", 0.0f);
granny.IsControllable = true;
}
else
{
granny.IsControllable = false;
selectLeftButton();
}
}
示例15: Awake
void Awake(){
panda_audio = this.gameObject.AddComponent<AudioSource>();
panda_audio.playOnAwake = false;
panda_audio.loop = false;
enu_audio = this.gameObject.AddComponent<AudioSource>();
enu_audio.playOnAwake = false;
enu_audio.loop = false;
// player = GetComponentInParent<Animator>();
last_trap_obj = null;
transform = GetComponentInParent<Transform> ();
player = transform.Find("panda").gameObject.GetComponentInParent<Animator>();
left_check = transform.Find(LEFT_CHECK);
right_check = transform.Find(RIGHT_CHECK);
up_check = transform.Find(UP_CHECK);
down_check = transform.Find(DOWN_CHECK);
if (stand_direction == 1) {
player.CrossFade ("down", 0);
} else if (stand_direction == 2) {
player.CrossFade ("stand_",0);
}else if(stand_direction == 3){
player.CrossFade ("left_stand_",0);
}else if(stand_direction == 4){
player.CrossFade ("right_stand_",0);
}
}