Trigger activating before entering trigger. What do I do?
Code:
using UnityEngine;
using System.Collections;
public class Switch : MonoBehaviour
{
GameObject Ball;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter(Collider coll)
{
if (coll.gameObject.tag == "Ball")
Debug.Log("Ball Entered! :)");
}
}
I have two objects. A ball, and a box. When the ball enters the box (which is marked as a trigger) it should do something (in this case send a message to me in console). Problem being is that it is activating before it ever hits the trigger. What do I do?
Is there any consistent behavior to when it's triggering? Such as randomly, only when you're moving toward it from a certain distance, etc?
Check the collider of the box (should show as a green outline when it's selected) and make sure it isn't somehow set larger than it should be.
@Ninamori As OncaLupe suggested, have a look at the collider on the box and make sure it is not to large, do the same with the ball game object. $$anonymous$$aybe the ball has a larger collider.
You can also have a look in the scene rather then the game play when you start. The script has no errors or not that I can gather.