I’m trying to detect when a “needle” goes through a target that is placed on a virtual paper. But when the needle gets close but definitely not hit the actual target, the OnCollisionEnter is triggered.
private Color targetColor;
private Color targetOriginalColor;
[SerializeField]
private GameObject targetToChangeColor;
void Start()
{
targetOriginalColor = targetToChangeColor.GetComponent<Renderer>().material.color;
}
void OnCollisionEnter(Collision collision)
{
targetColor = Color.green;
targetToChangeColor.GetComponent<Renderer>().material.color = targetColor;
}
void OnCollisionExit(Collision collision)
{
targetColor = targetOriginalColor;
targetToChangeColor.GetComponent<Renderer>().material.color = targetColor;
}
In the image you can see that the collider is even smaller than the circle (target). But it gets triggered as if it was 4-5 times larger. Also, nothing other than my needle and targets have colliders on them.
I have no ideas why this happens. Any help would be appreciated.