- Home /
Ignore collision in particular situation
My game contain two states for particular character. If my character in state 1 then I want collision need to be happen but in state 2 of same character I don't want any collision need to be happen.
So how to manage this type of situation through coding? I didn't have any idea at present.
Answer by siddharth3322 · May 05, 2014 at 04:48 AM
I have created multiple layer. One which detect collision and other one not.
Using collision matrix, Edit->Project Setting->Physics2D in this I handled collision manually and specify layer collision carefully.
So when I want collision don't happen at that time I changed layer of particular game object.
If you want any more detail about this then I will provide it. If this solution work for you also.
Answer by eshonbel · May 02, 2014 at 07:36 AM
Maybe have some variables for your different states. var State1 var State2
Then add a code for your different states. Then, use these if statements: //JavaScript function Update(){ if(State2 == true){ collider.isTrigger = true; } }
//hope this helps. i'm not a pro at coding ;)
Answer by VIPINSIRWANI · May 02, 2014 at 07:32 AM
Hi Siddharth, you can do one thing for that in second stage find the collider in run time and check property Is Tirigger true then after OnCollisionEnter will not work with that coolider.
I up vote your answer because it is one of the solution that work. But unfortunately this was not work for my game. I used another approach to handle same thing. But thanks for your reply.