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?

有帮助吗?

解决方案

You have a capitalization issue.

void OnTriggerEnter2D(Collider2D other) {
    //your handler code goes here!
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top