- Home /
2D collider troubles
Trying to make a method called once a player reaches a certain collider in the game but it doesn't seem to be registering that the player has touched the box collider... this is a 2D side scroller btw.
I have a script attached to a button, and once clicked the player starts running to the triggerObject, upon contact something should happen. However, I can't get a simple print to work so something is wrong. Here is the code I'm using.
public class StartScreen : MonoBehaviour {
public BoxCollider2D triggerrObject;
void OnTriggerEnter(Collider triggerObject)
{
print ("we collided");
}
}
you said its a 2D game , so you should change it to
void OnTriggerEnter2D(Collider2D triggerObject)
Answer by myzzie · Jan 17, 2018 at 06:20 AM
void OnTriggerEnter2D(Collider2D col)
{
print("We collided");
}
Tried, still isn't registering that the player is making contact
Do any of the gameobjects with a collider have a rigidbody2D? also make sure one of the colliders have the isTrigger checked
Your answer
Follow this Question
Related Questions
How can I move my BoxCollider2D ? 1 Answer
How to do collision in 2d game? 1 Answer
Problem with collision with two colliders simultaneously in Unity 2D 1 Answer
Collider lets object through 0 Answers