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;
}
}
}
网友评论