**已关闭。**此问题为not reproducible or was caused by typos。目前不接受答案。
这个问题是由一个打字错误或一个无法再重现的问题引起的。虽然类似的问题在这里可能是on-topic,但这个问题的解决方式不太可能帮助未来的读者。
2天前关闭。
Improve this question
我试图检测我的玩家的角色控制器何时接触到名为“water”的游戏对象,但我得到错误“The name 'collision' does not existed in the current context”。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerTouched : MonoBehaviour
{
public void OnControllerColliderHit(ControllerColliderHit hit)
{
if (collision.gameObject.tag == "Water")
{
Debug.Log("it worked!!");
}
}
}
我最初尝试使用OnCollisionEnter,但没有成功。
1条答案
按热度按时间jslywgbw1#
将您的方法更改为该方法,它将再次工作;