unity
欧皇大白兔
这个作者很懒,什么都没留下…
展开
-
Unity射线销毁
2、点击鼠标左键发射一条100米长的射线,当射线碰撞到游戏对象,游戏对象3秒后消失 public GameObject other; float timer = 3f; void Update() { //2、点击鼠标左键发射一条100米长的射线,当射线碰撞到游戏对象,游戏对象3秒后消失 if (Input.GetMouseButtonDown(0)) { //Ray ray = Camera.main.原创 2021-11-27 09:07:51 · 2886 阅读 · 0 评论 -
Unity角色碰撞检测
public class PZ : MonoBehaviour { CharacterController huang;//角色控制器 public GameObject shape;//玩家 public float speed = 50f;//移动速度 void Start () { huang = GetComponent<CharacterController>();//获取角色控制 } void Update () { float h = In...原创 2021-11-24 19:06:14 · 3761 阅读 · 0 评论 -
unity碰撞检测变色的简单应用
一开始物体带有初始颜色,碰撞到物体时变色(分别有黄色和蓝色)离开被碰撞物体时变色(红色,黑色,白色顺序切换)public class SE : MonoBehaviour { int a = 2; int b = 3; void OnTriggerEnter(Collider other)//触发器可以穿透,所以把重力去掉 // OnTriggerEnter:触发接触的那一帧被调用 { if (other.CompareTag("1"原创 2021-11-15 09:11:09 · 5564 阅读 · 1 评论 -
unity 简单的吃豆豆项目
第一张是项目结果图,2--4是项目过程图前四张是图,基本地形包括白色墙,玩家(红色球),豆豆(绿色方块,会自旋)后面是基本的移动代码,碰撞销毁代码,傻瓜操作即可先上图(这是项目运行之后的结果)这下面开始是过程玩家的移动和销毁豆豆(红色球是玩家)public class YiDong : MonoBehaviour { public float speed=5; void Update() { float h = Input.GetA...原创 2021-11-13 09:33:11 · 1824 阅读 · 0 评论 -
Unity的倒计时应用
public class DaoJiShi : MonoBehaviour { float timer = 10f;//十秒倒计时 public Text text;//显示面板 void Update () { if (timer<=1) { text.text = "游戏结束";//当游戏倒计时为0 显示游戏结束 timer=10;//重新更新时间,就会一直循环 } else { text.text = ((i.原创 2021-11-08 20:21:50 · 2052 阅读 · 0 评论 -
Unity的物体移动
C#脚本下的移动和旋转内容下次写原创 2021-11-06 00:20:15 · 850 阅读 · 0 评论