I have a shader that has a _Width var within the shader so I can change the distance away from the object the effect is. However I want to be able to animate this effect so that the Width float gets bigger each time the player hits the object.
So far I am setting up a key to test it and I have:
function Update () {
if (Input.GetKeyDown(“k”);
runPulse();
}
function runPulse(){
}
inside my function runPulse I want to have the changing of Width within the material that has the shader attached.
I assume I have to assign a var for the Width. how do I call that float? I cant figure out how to change Width (_Width) within my script with a simple +1;
thanks That helped a lot. Now Im just stuck on how to shrink my field.
What I am trying to accomplish is an electric pulse that expands and then when it reaches a max number it retracts.
Im attaching the project and the scene elecfield. If you play it now using the K button you can start the effect. When the effect reaches the number the shrink effect doesnt work right it goes right back to the start and stops.
Within the Script you’ll see our attempt to change the width to shrink over time. What am I doing wrong so far? 443934–15428–$Test_Elec_field.zip (883 KB)
an effect like this sounds like usage of time + cos / sin (depending on if you want to start at 0 or 1) as sin/cos will handle the pulsing itself and the time will ensure that it will paulse as the value always grows.