Question

Using Unity 4.3.4f

Scenario: I'm attempting to creating a background that moves with a camera object by using the Box Collider 2d and Rigidbody 2d attributes in order to create the feel that the background is looping as the camera moves across the screen.

The background elements are set to Is Trigger and the object on my camera that includes the detection script has a kinematic 2d rigidbody. To test if this works I just added the below script in C# to see if they collide.

void OnTriggerEnter2d(Collider2D collider) {
    Debug.Log ("Collision: " + collider.name);
}

In theory this should of course print the name of the object the collider makes contact with, right? For some reason I'm getting no output to my log. Any suggestions on what I'm not seeing here or a document I could review to figure out my problem?

Était-ce utile?

La solution

You have a capitalization issue.

void OnTriggerEnter2D(Collider2D other) {
    //your handler code goes here!
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top