Question by
Comicbook23 · Dec 26, 2021 at 04:32 AM ·
collisionrigidbodycollider3dcollision detection
Collision between objects not being detected
Hello! I am pretty new to Unity, but I'm challenging myself and trying to make a 3D Pokémon-type creature catching game. So, you know how in Pokémon games, you need to run in the tall grass to encounter a Pokémon? I have a 3D model for the grass that I made in Blender, as well as a basic 3D character model I made in Unity. I have a script that, right now, I simply want to detect when the character collides with the grass. Below is the code I have right now. I have a rigidbody on both the grass and the player, and I have a mesh collider on both. However, nothing is being printed to the console when the player model collides with the grass. I've tried other types of colliders, but that hasn't fixed the problem. What am I doing wrong?
private void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.name == "Grass")
{
Debug.Log("object check - colliding");
}
if(collision.gameObject.tag == "Grass")
{
Debug.Log("tag check - colliding");
}
}
Comment