N
N
netrox2017-10-06 08:52:48
Unity
netrox, 2017-10-06 08:52:48

How to change the color of an object in a unit when it touches another object?

By the way, if in the unit the "ball" object fell to the floor. How to change the color of the floor at the moment when the "ball" falls on it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Basmanov, 2017-10-06
@netrox

For collision detection there is MonoBehaviour.OnCollisionEnter and MonoBehaviour.OnCollisionStay . You hang a script with one of these methods on the floor and check if it was a ball or something else based on the incoming data. You can check for a layer, a tag, or the presence of a script.
And the color of the floor can be changed in a bunch of ways: turn on another renderer, replace the material, change the properties of the material, stuff it into the MaterialPropertyBlock renderer , turn on the animation ... etc. It's up to you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question