- Home /
How do I make a block pass through objects of the same color and be destroyed by objects of a different color?
I am trying to make a small project in which a block passes through walls that are the same color as the block but will be destroyed if it touches walls that are a different color than the block. I also want to add a feature that allows the block to change color between four colors depending on user input. It draws inspiration from the game Ikaruga. I, however, have no idea where to start on this particular script. Any help would be great and thank you for your time.
Answer by karl_jones · May 18, 2015 at 10:41 AM
Will tell you when an object collides: http://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html
In the collision code check the material of the other object and compare it to yours to see if they match colour.
You can also use the material to change colour based on user input.
Take a look at some of these tutorials to get you started: http://unity3d.com/learn/tutorials/modules/beginner/scripting
Good luck!