I have a scene in Unity, with animated assets. The animated asset is a custom prefab effect with multiple animated objects nested within it. The asset runs in a loop, all the objects are assigned a PBR shader using shadergraph. Some of the assets fade out at the end, while others simply disappear. I can control when an object disappears on the timeline by disabling it. But others need to fade away. I suspect I can fade out those objects by changing the alpha of the PBR shadergraph material at a specific point in time in the animation clip. Can anyone advise the process or links to tutorials on how to fade out an object, starting at a specific point in time in an animation clip, and also set the duration required when the object becomes completely invisible ?
How do you fade out an object in a scene from an animation clip?
2.1k views Asked by angryITguy At
1
To achieve what you wanted you would need to add an
AnimationEvent
into your Animaton.You can do that with the Rectangle Symbol you find over the Animation Window Properties.
You can now use that
AnimationEvent
to call a Function in a Script that will fade out the object.Also make sure to pass in what amount of time you want to fade the object as a
float
and the currentGameObject
as anObject
into the function.AnimationEvent Function:
RPBShader
would the Type of the Component you want to get.To fade out the Object over time we would need to use an
IEnumerator
.Fade Out Coroutine:
shader.alpha
would be the current's Object PBR Shader Alpha Value that you want to decrease.