'This message parameter has to be of type: Collision
I have done this in 3D. I don't have "is trigger" chosen in any objects. I wanted to write down "it works" when my object hit an object that is tagged "Obstacle". I need help.
using UnityEngine;
public class Collision : MonoBehaviour
{
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Obstacle")
{
Debug.Log("it works");
}
}
}
(I'm new to Unity so please try to explain as I could understand TYSM.)
Solution 1:[1]
You should add the Rigidbody component to the object. It is necessary for collision detection
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
