I Attempting to make a Script in Unity 2D.
Basically, when the Player touches a door collider, it is for him to do that "Degub.Log"
using UnityEngine;
public class ChangeScene : MonoBehaviour
{
void OnCollisionEnter2D(Collision2D collision)
{
if(collision.gameObject.name == "Door")
{
Debug.Log("Is On Door");
}
}
}
But, when i Toutch the Collisor, nothing happens.
How i Can Check if the collision game object name is "door"?
*I don't want to compare with any tag or layer, I want to compare with the name itself.
question from:
https://stackoverflow.com/questions/65879633/check-game-object-name-unity 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…