Hi everyone, So this is it, i am kind of new with Unity, and 2 friends and i we're making a 2D Platformer Game, our first one project and we really need help with something.. We want to make the player can detect a colision with a wall at the same time a colission withing a another wall is False (off) by pressing a key. We think that InCollisionEnter method could work, but we don't know how to make that happend. Here is an example about what we want to do
Have you looked at the unity tutorials, they will help explain everything common that you will need. Remember if you are using 2d stuff then you need to use the 2d collision & trigger detection. Have a bool on your player that is set by the button press & have tags on your walls etc then try using nested if/if else statements to check all the combos & do what you want with each combo
Here's some code I have from another project, I think this is what you're looking for So you'll need to add "Layers." Go to any game object and in the upper right look for Layers. Then click on the drop down box and go to Add Layers to create your own custom layers. So add a Light layer and a Dark layer. The following code will be set up where Light is layer 8, and Dark is layer 9. Next, go to Edit > Project Settings > Physics 2D. There you can set which layers will collide with each other. So set Light to collide with everything except Dark. Then set Dark to collide with everything except Light. Code (csharp): public bool isLight = false; void Update () { if (Input.GetKeyDown ("tab")) { if (isLight != true) { isLight = true; gameObject.layer = 8; //This causes the player's collision to align to whatever is on layer 8 Debug.Log ("You are now Light"); } else { isLight = false; gameObject.layer = 9; //This causes the player's collision to align to whatever is on layer 9 Debug.Log ("You are now Dark"); } } } Let me know how that works out for you Also in the future if you could state a specific time to look at in a video, it would be helpful to those trying to assist you.
Hi Gerarld, thank you very much for the code i apreciate your help, it work perfectly Do you know how i can make the platform a little bit transparent, maybe with a 50% opacity when it is triggered?