Need help on collision/colour change

Hi there!

Yesterday I had the simple idea of an keybordmoved cube that bump against another cube. That other cube should change colour.

That basic idea let me think about the old 70’s discofloors. On step change color, no step field is white. In other words, create a floor out of many cubes and move over it with the movable cube.

My question now: I played arround with collision zones but don’t get any effect on them. Is my “collision-colourchange” part of Engine or part of script (that I can’t realize yet lol)…

you can use gameObject.renderer.material.color = Color.red; for example, inside an OnColliderEnter(Collider other){} function.

PS: post code snippets next time, so we can see what you did wrong and help you.

I was just playing around with the Unity given stuff, no scripts… :wink:

Well you gotto make some scripts then! otherwise they won’t know what they need to do.

Ummm… When I start it, the bumped cube turns into red… Dunno why… When I place it some higher it turns into red hitting the floor…

Turning the cubes into Rigidbodys means, when I do the box collider size y lower then the cube itself, it falls into the floor till collider stops it… Hmhmhm

you can check IsKinematic on the Rigidbody and the box will not move or fall into the floor.

Indeed I tried this, but makin them Kine, collision doesn’t work anymore. I could move “through” the cube then. As I read now, the movescript make ignoring collision in Kinemode…

Edit: I placed a second cube over the other one. Running the whole thing, upper cube fall down and at collision both turn red, so: The moving script is definately the problem.

Final: K, I got it now. The moving cube is NOT Kinematic, all changecolourcubes R Kinematic. I made planes now with y scale 0,1 and position 0,001. It’s looking like n invisible chessgame. Moving with my cube over it they turn into red n blue. The moving cube is not “stumblin” over the planes. I see some black lines but that’s my smallest problem.

Text step is to make the an “uncollide-turn-white” script.

That also worked now with: function OnCollisionExit(collision : Collision)
Sure it’s a silly way to work with several objects and two scripts attached, but for me n now it’s ok. I reached my goal.

Why the hell I write that all down? Cos most threads stop with the solution and newbies can’t follow the rest (like me) :wink:

Ty to ppl who helped me with his really basic shyt! :sunglasses: