How can I use parameters value in the animation

Hi,

  1. I am trying to create an animation for a shield charge - that will set the transparency to the charge level gradually. the charge level is obviously not constant. the ugly way as I see it is writing a lot of logic in Update, but I would really like to refrain that. I tried using parameters but I can only use them as conditions not during the animation itself. how should this be implemented?

  2. I tried putting some part of the animation (the shield has a few parts) that is not parameterized into the Animation and the other into Update, but I figured they not both work, is that right?

Thanks,
Roy.

In this case, you dont want to use animations. You want to lerp the alpha value like this:

//C#
using UnityEngine;
using System.Collections;

public class ShieldCharge : MonoBehaviour {

    public float speed = 1.0f;

    void Awake(){

        GameObject.renderer.material.color.a = Mathf.Lerp(0.0, 1.0, Time.deltaTime * speed);

    }
}

Make a C# script called “ShieldCharge” and put it in the shield. When the script is activated, it will “charge” the shield.