當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。