本文整理汇总了C#中Animator.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Animator.GetComponent方法的具体用法?C# Animator.GetComponent怎么用?C# Animator.GetComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Animator
的用法示例。
在下文中一共展示了Animator.GetComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStateEnter
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (firstSetting)
{
this.IKController = animator.GetComponent<IKControllerHumanoid>();
this.toKeepDistanceHash = Animator.StringToHash("ToKeepDistance");
this.rollingHash = Animator.StringToHash("Rolling");
this.controller = animator.GetComponent<ControllerAIHumanoid>();
this.firstSetting = false;
}
if (!controller.isServer)
return;
if (Random.Range(0, 4) == 0)
{
animator.SetBool(rollingHash, true);
}
IKController.SetDefaultWeaponTarget();
controller.RVOController.enableRotation = true;
Vector3 thePointToFleeFrom = controller.CurrentEnemy.transform.position;
int theGScoreToStopAt = 1000;
FleePath path = FleePath.Construct(animator.transform.position, thePointToFleeFrom, theGScoreToStopAt);
path.aimStrength = 10;
controller.ManuallySetPath(path);
}
示例2: OnStateUpdate
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
public override void OnStateUpdate( Animator animator, AnimatorStateInfo stateInfo, int layerIndex )
{
var pos = Utils.Instance.GetPlayerByColor(animator.GetComponent<GameManager>().GetCurrentPlayer()).transform.position;
animator.GetComponent<CameraManager>().GetPlayerCamera().transform.position = Vector3.Lerp( animator.GetComponent<CameraManager>().GetMainCamera().transform.position,
new Vector3(pos.x + 4, pos.y + 5, pos.z - 15),
stateInfo.normalizedTime % 1.0f);
}
示例3: OnStateEnter
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (_enemy == null)
{
_enemy = animator.GetComponent<Enemy>();
_nma = animator.GetComponent<NavMeshAgent>();
}
_nma.speed = _enemy.moveSpeed;
}
示例4: OnStateExit
// OnStateExit is called when a transition ends and the state machine finishes evaluating this state
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
animator.GetComponent<GramophoneController>().MusicParticleSystem.Stop();
AudioSource audioSource = animator.GetComponent<AudioSource>();
if( audioSource != null )
{
audioSource.Stop();
}
}
示例5: 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");
}
示例6: 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)
{
//myBoxCollider = animator.transform.FindChild("Sword").GetComponent<BoxCollider>();
myBoxCollider = animator.GetComponent<PlayerController>().mySwordBoxCollider;
myWeaponAttack = animator.GetComponent<PlayerController>().mySwordsAttack;
myWeaponAttack.damage += 20;
myBoxCollider.enabled = true;
}
示例7: OnStateEnter
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (firstSetting)
{
this.shootingHash = Animator.StringToHash("Shooting");
this.IKController = animator.GetComponent<IKControllerHumanoid>();
this.controller = animator.GetComponent<ControllerAIHumanoid>();
this.firstSetting = false;
}
}
示例8: OnStateUpdate
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
GameObject[] players = GameObject.FindGameObjectsWithTag ("Player");
Attack attack = animator.GetComponent<AttackQueue> ().Attack;
Enemy enem = animator.GetComponent<Enemy> ();
Vector3 fromTo = enem.Target.transform.position - animator.transform.position;
if (fromTo.magnitude <= attack.collSize.magnitude) {
animator.SetFloat (AnimatorConstants.PUNCH, Random.value);
} else {
animator.SetFloat (AnimatorConstants.PUNCH, 0f);
}
}
示例9: OnStateUpdate
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
public override void OnStateUpdate( Animator animator, AnimatorStateInfo stateInfo, int layerIndex )
{
int currentIteration = Mathf.FloorToInt(stateInfo.normalizedTime);
if (currentIteration != _iteration)
{
_iteration = currentIteration;
if( currentIteration == animator.GetComponent<GameManager>().GetDiceNumber() )
{
Debug.Log("iter = " + currentIteration);
_currentPlayer.GetAnimator().Play("idle");
animator.GetComponent<CameraManager>().UnfocusOnPlayer(_currentPlayer.GetPlayerColor());
animator.GetComponent<GameManager>().NextPlayer();
animator.SetTrigger("PlayerFinishMoveTrigger");
ok = true; // NANDEEE
return;
}
else
{
var nextID = Utils.Instance.GetCaseByID(_currentPlayer.GetCaseID()).GetNextCaseID();
_currentPlayer.SetCaseID(nextID);
if (Utils.Instance.GetCaseByID(nextID).GetCaseType() == ECaseType.INTERSECTION)
animator.GetComponent<GameManager>().SetDiceNumber(animator.GetComponent<GameManager>().GetDiceNumber() + 1);
_startMarker = _currentPlayer.transform.position;
_endMarker = Utils.Instance.GetCaseByID(nextID).GetCasePosition(_currentPlayer.GetPlayerColor(), false);
float animLength = Vector3.Distance(_startMarker, _endMarker);
switch (_currentPlayer.GetPlayerColor())
{
case EPlayer.BLUE:
PlayerPrefs.SetInt("PLAYER_BLUE_CASEID", nextID);
break;
case EPlayer.GREEN:
PlayerPrefs.SetInt("PLAYER_GREEN_CASEID", nextID);
break;
case EPlayer.RED:
PlayerPrefs.SetInt("PLAYER_RED_CASEID", nextID);
break;
case EPlayer.YELLOW:
PlayerPrefs.SetInt("PLAYER_YELLOW_CASEID", nextID);
break;
}
animator.SetFloat("MoveInverseDuration", _speed / animLength);
}
}
if(!ok )//TODO : A voir !!
{
float fracJourney = stateInfo.normalizedTime % 1.0f;
_currentPlayer.transform.position = Vector3.Lerp(_startMarker, _endMarker, fracJourney);
_currentPlayer.transform.LookAt(_endMarker);
}
}
示例10: OnStateEnter
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (_player == null)
{
_player = animator.GetComponent<Player>();
_nma = animator.GetComponent<NavMeshAgent>();
_animator = animator;
}
_nma.speed = _player.moveSpeed;
_animator.SetBool("Run", true);
InputHandler.instance.enabled = true;
}
示例11: OnStateUpdate
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
Enemy en = animator.GetComponent<Enemy> ();
GameObject target = en.Target;
Vector3 fromTo = target.transform.position - animator.transform.position;
Vector3 added = fromTo.normalized * en.Speed * Time.deltaTime;
animator.transform.position += added;
if (fromTo.magnitude <= animator.GetComponent<AttackQueue> ().Attack.collSize.magnitude / 2) {
animator.SetBool (AnimatorConstants.TOOCLOSE, true);
} else {
animator.SetBool (AnimatorConstants.TOOCLOSE, false);
}
}
示例12: OnStateEnter
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (firstSetting)
{
this.shootingHash = Animator.StringToHash("Shooting");
this.IKController = animator.GetComponent<IKControllerHumanoid>();
this.controller = animator.GetComponent<ControllerAIHumanoid>();
this.firstSetting = false;
}
if (!controller.isServer)
return;
IKController.SetWeaponTarget(controller.CurrentEnemy.transform);
}
示例13: 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 (AnimationStateEvent == StateEvent.Enter)
//{
animator.GetComponent<RomanCharState>().SetState(characterState);
//Debug.Log("animator script, set: " + characterState);
//}
if (animator.GetComponent<RomanCharState>().GetState() == RomanCharState.State.Landing)
{
RSUtil.Instance.DelayedAction(() => {
animator.SetTrigger("Idle");
Debug.Log("FIRED");
}, 1f);
}
}
示例14: OnStateEnter
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
player = animator.GetComponent<Player>();
stateStartT = Time.time;
lastIdleTry = stateStartT + 1f;
lastRand = 100;
}
示例15: OnStateUpdate
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
public override void OnStateUpdate( Animator animator, AnimatorStateInfo stateInfo, int layerIndex )
{
if( Utils.Instance.GetPlayerByColor(animator.GetComponent<GameManager>().GetCurrentPlayer()).GetAnimPointMiddle() )
{
animator.SetTrigger("WheelFreezeTrigger");
}
}