I’ve looked around, but I haven’t quite found my question. I’m making a very simple game and one of the aspects of the game is pushing and pulling a box. I got that part figured out, but currently if the player stands on the box, they can pull it around. I tried fixing this by making the trigger close to the ground, but, I guess, on trigger enter works for colliders that aren’t marked as triggers as well.
I feel like I’m missing something obvious. I could, probably, just put this behavior in a child object and put the trigger there. But I want to know if there’s a smarter solution.
Relevant Code:
void OnTriggerEnter2D(Collider2D other){
if (other.tag == "Player") {
near = true;
//Debug.Log ("Near is:" + near);
}
}
void OnTriggerExit2D(Collider2D other){
if (other.tag == "Player") {
near = false;
//Debug.Log ("Near is:" + near);
}
}
Screenshot of Colliders:
