Ven Nilson
Ven Nilson

Reputation: 1019

Object did not collide with border

I'm stuck on this sphere has a CircleCollider2D and rectangle has a BoxCollider2D i increase the offset of BoxCollider. But why sphere not collide from it's border. Sphere go inside and then collide just like this.
enter image description here

I want that it's collide when sphere touch it's border.I also check with default radius but the same situation occur.

Upvotes: 1

Views: 314

Answers (1)

Burak Karasoy
Burak Karasoy

Reputation: 1690

Trigger

The scripting system can detect when collisions occur and initiate actions using the OnCollisionEnter function. However, you can also use the physics engine simply to detect when one collider enters the space of another without creating a collision. A collider configured as a Trigger (using the Is Trigger property) does not behave as a solid object and will simply allow other colliders to pass through. When a collider enters its space, a trigger will call the OnTriggerEnter function on the trigger object’s scripts. http://docs.unity3d.com/Manual/CollidersOverview.html

You need to close isTrigger and use OnCollisionEnter(...).

For example this is my script of wood(which is below ). A smaller wood will be going down. enter image description here

This is the beginning of my game enter image description here

If I set isTrigger option true, onCollisionEnter2D function doesn't work. I need isTriggerEnter() method instead. it goes through my wood layer. enter image description here

But if I set isTrigger false onCollisionEnter2D will be working. It will stay on my wood layer. enter image description here

Upvotes: 1

Related Questions