using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Fruit : MonoBehaviour
{
public int score = 0;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
Debug.Log(gameObject.tag);
Destroy(gameObject);
}
}
Unity加入道具水果
最新推荐文章于 2025-04-08 20:40:48 发布
本文介绍了一个简单的Unity2D游戏脚本实例,该脚本定义了一个名为Fruit的游戏对象类,当该对象与其他游戏对象发生碰撞时,会记录碰撞并销毁自身。此示例适用于Unity初学者学习2D碰撞检测。

800

被折叠的 条评论
为什么被折叠?



