自助游网站开发分析报告,做视频网站要什么软件,纯静态网站怎么做cdn,宁波建网站哪家好1、新建c#脚本如下
代码#xff0c;在前方生成生成自身图片并3s后销毁自身#xff0c;在碰撞物体后小鸟死亡后不删除自身
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class CopyScene : MonoBehaviour { //要复制的对象public…1、新建c#脚本如下
代码在前方生成生成自身图片并3s后销毁自身在碰撞物体后小鸟死亡后不删除自身
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class CopyScene : MonoBehaviour { //要复制的对象public GameObject copyObject;//生成在签发的距离public float front;private float time 0f;private bool isDestory false;// Start is called before the first frame updatevoid Start(){}// Update is called once per framevoid Update(){if (isDestoryFly.life) { time Time.deltaTime;if (time 3){//3s后销毁自身Destroy(transform.gameObject);}}}//当某个刚体触碰到了触发器private void OnTriggerEnter2D(Collider2D collision){//在前方复制物对象Instantiate(copyObject,new Vector3(transform.position.xfront,transform.position.y,transform.position.z),transform.rotation);isDestory true;}
}在背景图和地面下创建一个2D盒装碰撞器并勾选是触发器 按照2点击是触发器单小鸟移动到触发器位置则会触发脚本 按照3调整触发器大小及位置调整后就会看到4触发器的大小
3、拖拽脚本到bg图层种 4、地面、柱子也需要场景延续重复上面的操作即可