function OnCollisionEnter(theCollision : Collision){
if(theCollision.gameObject.name == “Floor”){
Debug.Log(“Hit the floor”);
}else if(theCollision.gameObject.name == “Wall”){
Debug.Log(“Hit the wall”);
}
}
本文介绍了一个简单的Unity脚本,用于处理游戏对象之间的碰撞事件。当游戏中的对象与地板或墙壁发生碰撞时,会输出相应的日志信息。
function OnCollisionEnter(theCollision : Collision){
if(theCollision.gameObject.name == “Floor”){
Debug.Log(“Hit the floor”);
}else if(theCollision.gameObject.name == “Wall”){
Debug.Log(“Hit the wall”);
}
}
1万+
1879

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