當前位置: 首頁>>代碼示例>>C#>>正文


C# Animator類代碼示例

本文整理匯總了C#中Animator的典型用法代碼示例。如果您正苦於以下問題:C# Animator類的具體用法?C# Animator怎麽用?C# Animator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Animator類屬於命名空間,在下文中一共展示了Animator類的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";

            }
        }
    }
開發者ID:oonyeje,項目名稱:BendingTempleAssets,代碼行數:28,代碼來源:EarthAttack.cs

示例2: Start

    // Use this for initialization
    void Start()
    {
        for (int i = 0; i < this.transform.childCount; i++) {
            GameObject obj = this.transform.GetChild(i).gameObject;
            Animator animator = obj.GetComponentInChildren<Animator>();
            this.animatorList.Add(animator);
            obj.SetActive(false);
        }

        switch (showType) {
        case ShowType.Enumeration: {
            for(int i = 0; i < animatorList.Count; i++){
                GameObject obj = animatorList[i].transform.parent.gameObject;
                obj.SetActive(true);
                float x = -20 + (i / 5) * 5;
                float y = 10 - (i % 5) * 5;
                Vector3 pos = new Vector3(x, y, i);
                obj.transform.localPosition = pos;
            }
            break;
        }
        case ShowType.Queue: {
            if(animatorList.Count >= 1){
                currentAnimator = animatorList[0];
                GameObject obj = currentAnimator.transform.parent.gameObject;
                obj.SetActive(true);
            }
            break;
        }
        }
    }
開發者ID:ootake,項目名稱:SpriteStudioForUnity,代碼行數:32,代碼來源:SampleManager.cs

示例3: Awake

    void Awake()
    {
        floorMask = LayerMask.GetMask("Floor");

        anim = GetComponent<Animator>();
        pRigidBody = GetComponent<Rigidbody>();
    }
開發者ID:BernardCastello,項目名稱:Dream-Guardian,代碼行數:7,代碼來源:PlayerMove.cs

示例4: Start

 void Start()
 {
     _t = transform;
     _animator = GetComponent<Animator>();
     _controller = GetComponent<CharacterController>();
     _rigidbody = GetComponent<Rigidbody>();
 }
開發者ID:choang05,項目名稱:Puzzle-2,代碼行數:7,代碼來源:SrpgcMouseMovementController.cs

示例5: Start

    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");

        anim = GetComponent<Animator>();
        charControl = GetComponent<CharacterController>();
    }
開發者ID:DanStout,項目名稱:FablesOfSol,代碼行數:7,代碼來源:ChasesPlayer.cs

示例6: Start

 // Use this for initialization
 void Start()
 {
     this.player = PlayerController.instance;
     this.rb2d = this.GetComponent<Rigidbody2D> ();
     this.melee = this.GetComponent<MeleeAttacker> ();
     this.animator = this.GetComponent<Animator> ();
 }
開發者ID:Endure-Game,項目名稱:Endure,代碼行數:8,代碼來源:Enemy1AI.cs

示例7: Start

	void Start () {
		this.anim1 = this.conversante1.GetComponent<Animator> ();
		this.anim2 = this.conversante2.GetComponent<Animator> ();
		
		this.texto = GameObject.Find ("Dialogo").GetComponent<Text> ();
		
		TextAsset archivo = Resources.Load(this.fichero) as TextAsset;
		this.contenidoFichero = archivo.text;
		this.conversaciones = this.contenidoFichero.Split ('\n');
		this.numConver = 0;
		this.primeraConversacion = true;
		this.siguienteConversacion = false;
		
		this.audioActual = this.gameObject.GetComponent<AudioSource> ();
		//Inicializamos el clip del audio.
		this.audioActual.clip = this.audio1;

		//Registramos la informacion del Analytics
		if (Tracker.T () != null) {
			this.registrarTracker ();
		}

		if (this.fichero == "Transicion1")
			this.anim2.SetBool("contenta", false);
	}
開發者ID:gorco,項目名稱:LaCortesiaDeEspa-a,代碼行數:25,代碼來源:ConversacionCutSceneSonido.cs

示例8: OnLevelWasLoaded

	void OnLevelWasLoaded(int level)
	{
		//opens eyes at the start of every level
			animator = this.GetComponent<Animator> ();
			animator.SetBool ("Open", true);
			eyesOpen = true;
	}
開發者ID:UCSDVR,項目名稱:Lucid-VR,代碼行數:7,代碼來源:BlinkScript.cs

示例9: AssignReferences

    void AssignReferences()
    {
        myCollider = GetComponent<Collider2D>();
        myCollider.isTrigger = true;

        animator = GetComponent<Animator>();
    }
開發者ID:imann24,項目名稱:Beauty,代碼行數:7,代碼來源:PlayAnimationOnCollide.cs

示例10: Start

	// Use this for initialization
    void Start()
    {
        rigid = GetComponent<Rigidbody2D>();
        box = GetComponent<BoxCollider2D>();
        esperando = espera;
        anim = GetComponent<Animator>();
	}
開發者ID:ValdesJuan,項目名稱:JimboGrimbo,代碼行數:8,代碼來源:Enemigo1.cs

示例11: Start

 protected void Start()
 {
     // get the Animator
     m_animator = gameObject.GetComponent<Animator>();
     m_initialRotation = transform.localRotation;
     m_initialPosition = transform.localPosition;
 }
開發者ID:DuckBossa,項目名稱:JeepneyDriverSimulator,代碼行數:7,代碼來源:SixenseHand.cs

示例12: Awake

 void Awake()
 {
     this.steering = this.gameObject.GetComponent<SteeringController>();
     this.animator = this.gameObject.GetComponent<Animator>();
     this.ik = this.animator.GetComponent<IKController>();
     this.RegisterWithIK();
 }
開發者ID:fgeraci,項目名稱:CS195-Core,代碼行數:7,代碼來源:BodyMecanim.cs

示例13: Start

	// Use this for initialization
	void Start () {

		//Get a component reference to the Character's animator component
		animator = GetComponent<Animator>();
		render = GetComponent<SpriteRenderer>();

		//Get the rigid body on the prefab
		bullBody = GetComponent<Rigidbody2D>();

		//Set our bullet strength and speed
		strength = 4;
		speed = 40;

		//Go after our player!
		player = GameObject.Find("Player").GetComponent<Player>();

		//Get our Player current Direction
		if (player.getDirection () > 0 ||
			(player.getDirection() == 0 && player.getLastDirection() > 0 )) {
			animator.SetInteger ("Direction", 1);
			playerRight = true;
		} else {
			playerRight = false;
			animator.SetInteger ("Direction", -1);
		}

		//Play our shooting sound
		shoot = GameObject.Find ("Shoot").GetComponent<AudioSource> ();

			shoot.Play ();

		//Get our camera script
		actionCamera = Camera.main.GetComponent<ActionCamera>();
	}
開發者ID:julianpoy,項目名稱:HackPoly2016,代碼行數:35,代碼來源:Bullets.cs

示例14: Awake

 //private float jumpVector = 0.5f; //factor needed in relation to vertical moving platforms
 void Awake()
 {
     anim = GetComponent<Animator> ();
     _speed = GetComponent<Boar_AI2> ().speed;
     _agroSpeed = GetComponent<Boar_AI2> ().agroSpeed;
     tempScale = new Vector3 (1, 1, 1);
 }
開發者ID:GuBaDa,項目名稱:SuperGreatGame,代碼行數:8,代碼來源:AnimationMobs.cs

示例15: Start

	// Use this for initialization
	void Start () {
		rbd2D = GetComponent<Rigidbody2D> ();
		anim = GetComponent<Animator> ();
		aL = (Arrow_Launch)FindObjectOfType (typeof(Arrow_Launch));
		directEnemy = (Enemy_Controller)FindObjectOfType (typeof(Enemy_Controller));
		pStatus = (Player_Status)FindObjectOfType (typeof(Player_Status));
	}
開發者ID:godfavornoone,項目名稱:TWTW-Real,代碼行數:8,代碼來源:Player_Controller.cs


注:本文中的Animator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。