I need to create this script, please.
When you press W so as to perform the animation “dopredu.anim”
And if I let the press so that the animation stopped.
Can’t see how what you ask for is related to a light?
Are you wanting the animation to only play whilst the W key is pressed?
You could do a check if the W key is pressed to play the animation.
And when the key is released to stop as two distinct events.
If you need to readup more on animation scripting then there is a good introduction in the documentation section
You will need to have an animation component added to your gameobject. In the update of a new script applied to the object
function Update () {
if (Input.GetKeyDown (“w”))
animation.Play(“dopredu”, PlayMode.StopAll);
if (Input.GetKeyUp(“w”))
animation.Stop(“dopredu”);
}