Snow deformation over time - how to code it

Hi, so Chris showed snow accumulation over time using sliders in inspector graph… Well I won’t be there for every player to do that for them. So how can you do that by monobehaviour?

Tough to give an answer because we don’t know what you are talking about? Which course is this for?

I’m going to assume it’s for the shadergraph course.

  • You will see that you have added an Amount field in the blackboard. You will adjust this in the code. If you click on amount (in the shader graph editor) and look at the node config part, it will have a name (Amount) and a reference (_Amount). Copy this reference to your clipboard.
    image

  • In whichever MonoBehaviour you want, you need a reference to the material that uses this shader

[SerializeField] Material _snowMaterial;
  • Set the value on this material using the reference you copied - remember that the value should be between 0 and 1. I’m just going to use a random value as an example
_snowMaterial.SetFloat("_Amount", Random.value);

That’s it. Now you’ve set the amount on the snow. No need to take time out of your busy day to go and set it for every player

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms