How can you make an object visible in Unity when you jump on it?

I’m trying to make a game where you first only see the shadows of the objects, and as soon as you jump on it, it should make the object visible. Does anyone know how to do that?

Hi,

Split your problem to parts, then figure out how to implement each part.

Objects with only shadows visible: set your MeshRenderer Cast Shadows to Shadows Only. This should only make the shadows visible, but not the mesh itself.
See manual:

Making the change in visibility could be accomplished by adding a collider/trigger to the object. Then create a script which reacts to the player collision (or whatever it is that collides).
You can find many examples on how to write a collider/trigger script on these forums, Unity answers and in the docs too, just search for it.

Anyway, when the collision event is detected, you would then change the shadow setting in your object. You would need to either reference the mesh renderer as a cached variable (assign it in Inspector for example) or pick a reference from the collision event. You can find many examples how to do this. Search for something like “get mesh renderer of a collider object” or something similar.

1 Like