面向组件编程之Unity 6.怎样复制游戏物体 关键字:time/<GameObject>/Instantiate/Debug
2017-12-12 09:44
781 查看
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 3.怎样获取脚本所在物体的各种组件 例如:GetComponentInChildren<T>()/GetComponentsInChildren<U>()
- 面向组件编程之Unity 4.怎样得到游戏场景中的对象 例如:layer/tag&&SetActive隐藏游戏物体
- 面向组件编程之Unity 7.怎样脚本控制物体旋转和移动 关键字:画圆&&Translate/transform.Translate,transform.Rotate
- 面向组件编程之Unity 11.Quaternion类属性 线性插值Lerp() 关键字:按键控制游戏物体朝向
- 面向组件编程之Unity 9.计时器 关键字:Time,Time.deltatime
- 面向组件编程之Unity 1.怎样获取脚本所在物体的各种组件,例如:transform/BoxCollider
- 面向组件编程之Unity 8.按键控制 关键字:bool,GetKey,KeyCode
- Tips10:你可以像写文档一样自由的复制粘贴游戏组件(Game Object Component)
- <Unity3D>使用Unity来制作俄罗斯方块游戏
- Unity_ GetComponentsInChildren<T>(Bool includeInactive) 获取自己和它的孩子有同样的组件
- 【Unity3D基础教程】给初学者看的Unity教程(一):GameObject,Compoent,Time,Input,Physics
- [Unity小技巧]复制组件数值粘贴至另一个物体的组件
- 【Unity入门】场景、游戏物体和组件的概念
- 【Unity入门】场景、游戏物体和组件的概念
- 怎样让 表中的数据 <a href='aa'>Game</a> 原本的显示在网页中
- OC学习--<猜拳游戏> 之 通过面向对象思想实现
- 【Unity3D基础概念】给初学者看的Unity概览(一):GameObject,Compoent,Time,Input,Physics
- 「游戏引擎Mojoc」(4)面向组件-状态机-消息驱动3合1编程模型
- OC学习--<猜拳游戏> 之 通过面向对象思想实现
- Unity官方第一人称射击游戏<恶魔射手>_学习笔记三(敌人脚本)