using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TransformFeng2 : MonoBehaviour
{
//bullet
public GameObject cubebullet;
//发射点
public Transform tra;
//时间
float Timer = 0;
// Update is called once per frame
void Update()
{
//每帧加一帧的时间
Timer += Time.deltaTime;
//每两秒复制一次
if (Timer > 2)
{
//<>泛型,cubebullet复制物体,一般为预设体。tra.position复制坐标,tra.rotation复制角度
GameObject bullet = Instantiate<GameObject>(cubebullet, tra.position, tra.rotation);
Timer = 0;
Debug.Log("每隔两秒复制一次");
}
}
}
面向组件编程之Unity 6.怎样复制游戏物体 关键字:time/<GameObject>/Instantiate/Debug
最新推荐文章于 2024-06-23 09:07:53 发布