当前位置: 首页>>代码示例>>C#>>正文


C# Animator.GetComponent方法代码示例

本文整理汇总了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);
    }
开发者ID:Alx666,项目名称:ProjectPhoenix,代码行数:26,代码来源:AIHumanoidKeepDistanceSM.cs

示例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);
 }
开发者ID:VisualPi,项目名称:LOQUET_TIXIER_WATHTHUHEWA_Projet_Annuel,代码行数:8,代码来源:CameraZoomState.cs

示例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;
 }
开发者ID:Lobo-Prix,项目名称:TeraTale,代码行数:9,代码来源:EnemyChasing.cs

示例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();
		}
	}
开发者ID:meli-ismyself,项目名称:gdg2015-project,代码行数:10,代码来源:GramophonePlayingBehaviour.cs

示例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");
 }
开发者ID:sircuddles,项目名称:inScope-Studios-2D-Platformer,代码行数:14,代码来源:AttackBehavior.cs

示例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;
    }
开发者ID:Unityprojektgruppe2,项目名称:Unity-Project---Group-2-NEW,代码行数:10,代码来源:AttackAnimationBehaviour.cs

示例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;
     }
 }
开发者ID:Alx666,项目名称:ProjectPhoenix,代码行数:10,代码来源:HumanoidReadyToAim.cs

示例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);
		}
	}
开发者ID:kunodev,项目名称:GGJ2016,代码行数:12,代码来源:BaseStateMachineScript.cs

示例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);
        }
    }
开发者ID:VisualPi,项目名称:LOQUET_TIXIER_WATHTHUHEWA_Projet_Annuel,代码行数:54,代码来源:PlayerMoveState.cs

示例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;
 }
开发者ID:Lobo-Prix,项目名称:TeraTale,代码行数:12,代码来源:PlayerRunning.cs

示例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);
		}
	}
开发者ID:kunodev,项目名称:GGJ2016,代码行数:14,代码来源:MoveTowards.cs

示例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);
    }
开发者ID:Alx666,项目名称:ProjectPhoenix,代码行数:14,代码来源:HumanoidShootSM.cs

示例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);
            }
    }
开发者ID:pencilking2002,项目名称:Tails-of-Fury-movement-prototype,代码行数:17,代码来源:SetState.cs

示例14: OnStateEnter

 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     player = animator.GetComponent<Player>();
     stateStartT = Time.time;
     lastIdleTry = stateStartT + 1f;
     lastRand = 100;
 }
开发者ID:cdeeg,项目名称:ChickenTikkaMassacre,代码行数:7,代码来源:PlayerState_Idle.cs

示例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");
     }
 }
开发者ID:VisualPi,项目名称:LOQUET_TIXIER_WATHTHUHEWA_Projet_Annuel,代码行数:8,代码来源:PlayerStartPointingState.cs


注:本文中的Animator.GetComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。