Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class RadialLineRenderer : MonoBehaviour
- {
- LineRenderer lr;
- [Range(-1f,1f)]public float wave = 0.5f,spin = 0.5f;
- public float radius = 3f;
- public int verts = 500;
- [Range(2,8)]public int armCount = 5;
- [Range(0.5f,16f)]public float armPower = 0.5f;
- void Start ()
- {
- if (lr == null)
- lr = GetComponent(typeof(LineRenderer)) as LineRenderer;
- if (lr == null)
- lr = gameObject.AddComponent(typeof(LineRenderer)) as LineRenderer;
- }
- void Update ()
- {
- if (lr == null)
- return;
- lr.SetVertexCount(verts);
- for ( int i = 0 ; i < verts ; i++)
- {
- Vector3 p = transform.position;
- float a = ((float)i / ((float)verts-1f)) * 2f * Mathf.PI;
- float mod = Mathf.Pow(0.5f+0.5f*Mathf.Sin( a * armCount + Time.time * spin * 2f),armPower) * radius * wave;
- float r = mod + radius;
- p.x += r * Mathf.Cos ( a );
- p.y += r * Mathf.Sin ( a );
- lr.SetPosition(i , p);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment