使用

作者: 貪狼大人 | 来源:发表于2017-11-01 21:18 被阅读0次
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class haha : PoolController
    {
        GameObject ziji;
        // Use this for initialization
        void Start()
        {
            ziji = GameObject.Find("Capsule");//任意gameobject,我用的是胶囊体
        }
        // Update is called once per frame
        void Update()
        {
            
            if (Input.GetKeyDown(KeyCode.F))
            {
                StartCoroutine(biu());
            }
        }
        IEnumerator biu()
        {
            
            float timer = 0;
            GameObject o = Spawn("Bullet");
            o.transform.position = ziji.transform.position;
            o.GetComponent<Rigidbody>().AddForce(ziji.transform.forward.normalized * 200);
            while (timer < 3)
            {
                yield return new WaitForSeconds(1);
                timer += 1;            
            }      
            print(timer);
            
            //o.transform.Translate(transform.forward * 5 *Time.deltaTime);
            if (timer >= 3)
            {
                UnSpawn(o);
                timer = 0;
            }
            
    
        }
        
    }
    
    

    相关文章

      网友评论

          本文标题:使用

          本文链接:https://www.haomeiwen.com/subject/jtcnpxtx.html