Home > Back-end >  (Unity) Is there a way to animate Line Renderer without code?
(Unity) Is there a way to animate Line Renderer without code?

Time:12-20

I'm prototyping a 2D space shooter, and i wanted a secondary special attack that creates a laser, completely kinematic, coming out of the ship's front. I've done the laser using Line Renderer and the Bloom Post Processing effect.

So I was wondering if it is possible to animate the line renderer on the animator. I've tried to do it but it seems that the animator, as far as I can see on my Unity 2019.2.17f1 version, that it only appears to allow animations for the Line Renderer's material-related stuff, not related to the position array (curve), aside from the Width multiplier property, which I also need but isnt sufficient for the animation

Maybe I'm missing a name but it seems that you cant really modify the parameters if it's not via code.

Any ideas?

CodePudding user response:

I'm not sure if or why it is not possible but most probably it is due to the fact that it is an array unlike all the properties you usually animate which are single values.

What you could do though if it is only supposed to animate e.g. the end point have a component like e.g.

public class LaserController : MonoBehaviour
{
    public LineRenderer line;

    public bool enableLaser;
    public Vector3 endPoint;

    private void LateUpdate ()
    {
        line.enabled = enableLaser;
        line.SetPosition(1, endpoint);
    }
}

And simply animate the fields of that one.

CodePudding user response:

The answer is there isnt, and i switched to particle system for a more simple use.

  • Related