Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class DrawCircle : MonoBehaviour
- {
- float theta_scale = 0.01f; //Set lower to add more points
- int size; //Total number of points in circle
- [SerializeField]
- float radius = 13f;
- [SerializeField]
- LineRenderer lineRenderer;
- void Awake()
- {
- float sizeValue = (2.0f * Mathf.PI) / theta_scale;
- size = (int)sizeValue;
- size++;
- //lineRenderer = gameObject.AddComponent<LineRenderer>();
- //lineRenderer.material = new Material(Shader.Find("Particles/Additive"));
- lineRenderer = gameObject.GetComponent<LineRenderer>();
- lineRenderer.startWidth = 0.1f;
- lineRenderer.endWidth = 0.1f;
- lineRenderer.positionCount = size;
- }
- void Update()
- {
- Vector3 pos;
- float theta = 0f;
- for (int i = 0; i < size; i++)
- {
- theta += (2.0f * Mathf.PI * theta_scale);
- float x = radius * Mathf.Cos(theta);
- float z = radius * Mathf.Sin(theta);
- x += gameObject.transform.position.x;
- z += gameObject.transform.position.z;
- pos = new Vector3(x, gameObject.transform.position.y, z);
- lineRenderer.SetPosition(i, pos);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement