2D Wave Methods ?

Hi,

I’m trying to develop a game which creates a wave vertically. I’m using trail renderer now bu is there a better way i can apply ? A better and smoother algorithm ?

[42840-ekran-alıntısı.png|42840]

this is my trail renderer wave example.

Manipulating the lineRenderer with a Sine wave algorithm may give you the effect you’re seeking. You’ll probably have to tinker with the code some more, but it seems like a good start:

example.cs

    using UnityEngine;
    using System.Collections;
     
    public class example : MonoBehaviour {
        public Color c1 = Color.yellow;
        public Color c2 = Color.red;
        public int lengthOfLineRenderer = 20;
        void Start() {
            LineRenderer lineRenderer = gameObject.AddComponent<LineRenderer>();
            lineRenderer.material = new Material(Shader.Find("Particles/Additive"));
            lineRenderer.SetColors(c1, c2);
            lineRenderer.SetWidth(0.2F, 0.2F);
            lineRenderer.SetVertexCount(lengthOfLineRenderer);
        }
        void Update() {
            LineRenderer lineRenderer = GetComponent<LineRenderer>();
            int i = 0;
            while (i < lengthOfLineRenderer) {
                Vector3 pos = new Vector3(i * 0.5F, Mathf.Sin(i + Time.time), 0);
                lineRenderer.SetPosition(i, pos);
                i++;
            }
        }
    }

http://forum.unity3d.com/threads/creating-a-sine-wave.187154/#post-1278909

http://forum.unity3d.com/threads/creating-a-plane-from-an-array-of-vector3s-2d-water.187151/