• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Animator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Animator的典型用法代码示例。如果您正苦于以下问题:C# Animator类的具体用法?C# Animator怎么用?C# Animator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Animator类属于命名空间,在下文中一共展示了Animator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Start

	// Use this for initialization
	void Start () {
		Screen.autorotateToPortrait = false;
		Screen.autorotateToPortraitUpsideDown = false;
		animator = GetComponent<Animator>();	
		forwardMovementSpeed = initialForwardMovementSpeed;
		Debug.Assert(social != null && leaderboards != null);
	}
开发者ID:xtralifecloud,项目名称:RocketMouse-Social,代码行数:8,代码来源:MouseController.cs


示例17: 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
	override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) 
	{
		if(stateInfo.IsName("LongGunPullOut"))
		{
			animator.GetComponent<CharacterReference>().ParentCharacter.MyAnimEventHandler.TriggerOnLongGunPullOutFinish();
		}
		else if(stateInfo.IsName("SmallWeaponPullOut"))
		{
			animator.GetComponent<CharacterReference>().ParentCharacter.MyAnimEventHandler.TriggerOnPistolPullOutFinish();
		}
		else if(stateInfo.IsName("LongGunPutAway"))
		{
			animator.GetComponent<CharacterReference>().ParentCharacter.MyAnimEventHandler.TriggerOnLongGunPutAwayFinish();
		}
		else if(stateInfo.IsName("SmallWeaponPutAway"))
		{
			animator.GetComponent<CharacterReference>().ParentCharacter.MyAnimEventHandler.TriggerOnPistolPutAwayFinish();
		}
		else if(stateInfo.IsName("GrenadePullOut"))
		{
			animator.GetComponent<CharacterReference>().ParentCharacter.MyAnimEventHandler.TriggerOnGrenadePullOutFinish();
		}
		else if(stateInfo.IsName("MeleeDraw"))
		{
			animator.GetComponent<CharacterReference>().ParentCharacter.MyAnimEventHandler.TriggerOnMeleePullOutFinish();
		}
	}
开发者ID:rotorist,项目名称:Warzone,代码行数:38,代码来源:WeaponSwitchNotify.cs


示例18: Start

    void Start()
    {
        animator = GameObject.Find("Player").GetComponent<Animator>();
        if (!animator)
        {
            Debug.LogError("Missing animator!");
        }

        basePlayer = GameObject.Find("Player").GetComponent<BasePlayer>();
        if (!basePlayer)
        {
            Debug.LogError("Missing BasePlayer script!");
        }

        audioSource = GameObject.Find("Player").GetComponent<AudioSource>();
        if (!audioSource)
        {
            Debug.LogError("Missing audio source!");
        }

        if (!cooldownIndicator)
        {
            Debug.LogError("Missing cooldown button!");
        }

        if (clip.Length == 0)
        {
            Debug.LogError("0 sounds for attacking!");
        }

        timer = 0f;
        targets = new List<BaseNPC>();
        attacking = false;
    }
开发者ID:Morthalin,项目名称:TheGame,代码行数:34,代码来源:WhirlwindAttack.cs


示例19: Awake

 void Awake()
 {
     rb2d = GetComponent<Rigidbody2D>();
     anim = GetComponent<Animator>();
     aud = GetComponent<AudioSource>();
     jps = transform.GetChild(2).GetComponent<ParticleSystem>();
 }
开发者ID:9,项目名称:Swordface2.5D,代码行数:7,代码来源:IcosaEnemyBrain.cs


示例20: Awake

 void Awake()
 {
     anim = GetComponent <Animator> ();
     playerAudio = GetComponent <AudioSource> ();
     playerMovement = GetComponent <PlayerMovement> ();
     currentHealth = startingHealth;
 }
开发者ID:chris-chris,项目名称:Chapter6,代码行数:7,代码来源:PlayerHealth.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Annotation类代码示例发布时间:2022-05-24
下一篇:
C# AnimationType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap