本文整理汇总了C#中UnityEngine.AnimatorStateInfo类的典型用法代码示例。如果您正苦于以下问题:C# AnimatorStateInfo类的具体用法?C# AnimatorStateInfo怎么用?C# AnimatorStateInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AnimatorStateInfo类属于UnityEngine命名空间,在下文中一共展示了AnimatorStateInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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(animator.gameObject.GetComponent<Enemy>().indexPos == 0){
if(animator.GetInteger("attack") == 1){
GameObject EarthBend = (GameObject)Instantiate(Resources.Load("EarthBend", typeof(GameObject)), GameObject.Find("skillSpawn(1)").transform.position, GameObject.Find("skillSpawn(1)").transform.rotation);
EarthBend.GetComponent<Rigidbody>().velocity = EarthBend.transform.TransformDirection(Vector3.forward * 15);
EarthBend.transform.FindChild("source").gameObject.tag = "Enemy1Attack";
}
}
if(animator.gameObject.GetComponent<Enemy>().indexPos == 1){
if(animator.GetInteger("attack") == 1){
GameObject EarthBend = (GameObject)Instantiate(Resources.Load("EarthBend", typeof(GameObject)), GameObject.Find("skillSpawn(2)").transform.position, GameObject.Find("skillSpawn(2)").transform.rotation);
EarthBend.GetComponent<Rigidbody>().velocity = EarthBend.transform.TransformDirection(Vector3.forward * 15);
EarthBend.transform.FindChild("source").gameObject.tag = "Enemy2Attack";
}
}
if(animator.gameObject.GetComponent<Enemy>().indexPos == 2){
if(animator.GetInteger("attack") == 1){
GameObject EarthBend = (GameObject)Instantiate(Resources.Load("EarthBend", typeof(GameObject)), GameObject.Find("skillSpawn(3)").transform.position, GameObject.Find("skillSpawn(3)").transform.rotation);
EarthBend.GetComponent<Rigidbody>().velocity = EarthBend.transform.TransformDirection(Vector3.forward * 15);
EarthBend.transform.FindChild("source").gameObject.tag = "Enemy3Attack";
}
}
}
示例2: OnStateExit
// 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)
{
// In case it is not destroyed for some reason when it depends on the animation
if (DependOnThisState && _spawnedGameObject != null) {
Destroy(_spawnedGameObject);
}
}
示例3: GetAnimatorNameHash
public static int GetAnimatorNameHash(AnimatorStateInfo animatorStateInfo) {
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
return animatorStateInfo.nameHash;
#else
return animatorStateInfo.fullPathHash;
#endif
}
示例4: OnStateUpdate
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
FootPlacementData lF1 = animator.GetComponents<FootPlacementData>()[0];
FootPlacementData lF2 = animator.GetComponents<FootPlacementData>()[1];
//setting up first foot transition time and extra ray dist check
if (lF1 != null)
{
if(stateInfo.normalizedTime > 0.25f)
{
lF1.mExtraRayDistanceCheck = mIdleRayCast;
}
else
{
lF1.mExtraRayDistanceCheck = 0;
}
}
//setting up second foot transition time and extra ray dist check
if (lF2 != null)
{
if(stateInfo.normalizedTime > 0.25f)
{
lF2.mExtraRayDistanceCheck = mIdleRayCast;
}
else
{
lF2.mExtraRayDistanceCheck = 0;
}
}
}
示例5: UpdateAnimator
//**********************************************************************************//
// ANIMATOR //
// update animations at the animator controller (Mecanim) //
//**********************************************************************************//
public void UpdateAnimator()
{
if (ragdolled)
DisableActions();
else
{
stateInfo = animator.GetCurrentAnimatorStateInfo(0);
actions = jumpOver || stepUp || climbUp || rolling;
RandomIdle();
RollForwardAnimation();
QuickTurn180Animation();
QuickStopAnimation();
LandHighAnimation();
JumpOverAnimation();
ClimbUpAnimation();
StepUpAnimation();
ControlLocomotion();
animator.SetBool("Aiming", aiming);
animator.SetBool("Crouch", crouch);
animator.SetBool("OnGround", onGround);
animator.SetFloat("GroundDistance", groundDistance);
animator.SetFloat("VerticalVelocity", verticalVelocity);
}
}
示例6: OnStateEnter
public override void OnStateEnter(
Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
this.animator = animator;
GameManager.PlayerInteraction.PowerupOn += OnPlayerPowerupOn;
GameManager.PlayerInteraction.PowerupOff += OnPlayerPowerupOff;
}
示例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)
{
Debug.Log("Stop");
var rigidbody = animator.GetComponentInParent<Rigidbody>();
store = rigidbody.constraints;
rigidbody.constraints = RigidbodyConstraints.FreezeAll;
}
示例8: 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;
}
}
}
示例9: OnStateEnter
public RomanCharState.State characterState; // Which state to switch into on enter
// 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)
{
GameManager.Instance.charState.SetState(characterState);
// RSUtil.Instance.DelayedAction (() => {
// GameManager.Instance.charState.SetState(characterState);
// }, 0.2f);
}
示例10: Update
void Update()
{
_startN = 0.0f;
_endN = 0.0f;
_animationState = mAnimator.GetCurrentAnimatorStateInfo (0);
SwoonNode snode = System.Array.Find (_animations, xx => _animationState.IsName (xx.clipname));
if (snode != null)
{
_time = _animationState.normalizedTime - Mathf.Floor(_animationState.normalizedTime);
float frames = (int)(_animationState.length*30);
_startN = snode.start / frames;
_endN = snode.end / frames;
if (_time >= _startN && _time < _endN)
{
_trails.ForEach(x=>x.Emit = true);
}
else
{
_trails.ForEach(x=>x.Emit = false);
}
}
else
{
_time = 0f;
//_prevTime = _time;
//_prevAnimTime = 0f;
}
}
示例11: 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)
{
myBoxCollider = animator.GetComponent<PlayerController>().mySwordBoxCollider;
myBoxCollider.enabled = false;
animator.SetBool("Whirlwinding", false);
}
开发者ID:Unityprojektgruppe2,项目名称:Unity-Project---Group-2-NEW,代码行数:16,代码来源:WhirlwindStopAnimationBehaviour.cs
示例12: 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 (Player.Instance.OnGround) {
animator.SetBool("land", false);
animator.ResetTrigger("jump");
}
}
示例13: OnStateUpdate
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
Vector3 newPos = originalPos;
newPos.y = newPos.y + yOffset;
animator.transform.position = newPos;
}
示例14: 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" );
}
示例15: FixedUpdate
void FixedUpdate()
{
currentBaseState = animator.GetCurrentAnimatorStateInfo(0); //Indica la capa de animacion
int currentState = currentBaseState.nameHash;
int state = (int)states.currentState;
animator.SetFloat("Direction",Input.GetAxis("Horizontal"));
animator.SetFloat("Speed",Input.GetAxis("Vertical"));
animator.SetBool("Jump",false);
if (Input.GetAxis("Vertical") > 0.1f){
animator.SetBool("Walk",true);
}else{
animator.SetBool("Walk",false);
}
switch (currentState){
case idleState:
if (Input.GetButtonDown("Jump")){
animator.SetBool("Jump",true);
}
break;
case walkState:
if (Input.GetButtonDown("Jump")){
animator.SetBool("Jump",true);
}
break;
case walkbackState:
if (Input.GetButtonDown("Jump")){
animator.SetBool("Jump",true);
}
break;
default:
break;
}
}