Make and object invisible while in motion? (3d)

Hey guys! I am working on a concept in which objects become invisible while the player is in motion and are visible while standing still. I still want the rigidbody and collider to be active while the object is invisible. Does anyone know how to create something like this?

Thanks!

One way to approach this would be using shaders attached to those objects. You could make a shader which supports transparency, then modify that value using something like:

int movementMultiplier = (playerRigidbody.velocity.sqrMagnitude > 0.001f) ? 0 : 1;
Shader.SetGlobalFloat("_PlayerMoving", movementMultiplier);

Then, in your shaders, define and use:

float _PlayerMoving;
// ...
finalColor.a = saturate(_PlayerMoving);

I know this answer isn’t especially comprehensive and thorough, but hopefully this may provide some food for thought.

Could you just disable the MeshRenderer component?

if (isMoving) { // however you want to determine this
    GetComponent<MeshRenderer> ().enabled = false; // could cache MeshRenderer for performance
} else {
    GetComponent<MeshRenderer> ().enabled = true;
}