[Unity 3D] Dynamically modify collider 2D

Problem

You would like to modify/update game object’s collider (EdgeCollider2D) from the code behind. Collider is marked as “Is Trigger” but you are not getting any events (like OnTriggerEnter2D, OnTriggerStay2D or OnTriggerExit2D).

Why

Took me at least few hours to find out that collider cannot be inside other collider, otherwise (apparently) Unity will optimize it and remove it.

Solution

When you add collider that you want to modify in runtime, make sure it’s outside of another one. On the picture below you will see I am using BoxCollider around player. Inside it I added EdgeCollider 2D that I wanted to update when user is moving. When EdgeCollider was inside BoxCollider, it didn’t trigger any events. If you move it outside of it, everything will start working.

 

Notes

EdgeCollider 2D will “collide” however when “Is Trigger” is not marked. Then his initial position can be inside of the other collider.

Thanks!

We are on WP Central! Thanks!

Two days ago Roman Empire was featured on WP Central! It’s a great news for us. Thanks to that article a lot of people tried the game even before it got into “New+rising” category in the Windows Phone store, which is today.

Link: http://www.wpcentral.com/roman-empire-invades-windows-phone-8-and-windows-8

We would like to thank especially to article’s author for such a nice review and sharing feedback so we can improve the game for you guys!

Thanks!

Roman Empire on Windows Phone released!

Finally Roman Empire is available also on Windows Phone. Try it now and add your review. Any 5 stars are extremely important after release so the game will not be forgotten among other hundreds of thousands. I hope you can help.

This time I am also trying different approach and I made game 100% free but with ads. I am looking forward your feedback.

Those who played Roman Empire on Windows 8 will find most of the levels similar to Windows 8. I tried to tweak them a little bit but in general they are the same. I think it’s better to focus on new levels for Windows 8 and Phone version in the future, than spending too much time on new set just for phone.

Link: http://www.windowsphone.com/s?appid=5b7b76de-810f-4bf6-b372-423afb3617d6

Welcome!

It’s time to start our small website. You will find here all news about our mobile games and products.

Our goal is to create mobile games that everyone can play for 1-10 minutes in places like buses, hair saloons or restrooms. Games that can be stopped in every moment and continued later.

If you don’t have hours to play but too often you are bored for short period of time, this is the right place for you!