Skip to content

Instantly share code, notes, and snippets.

@smkplus
Created June 23, 2020 19:28
Show Gist options
  • Save smkplus/1f3f6b46a0a54db3353cc90bc048d6e9 to your computer and use it in GitHub Desktop.
Save smkplus/1f3f6b46a0a54db3353cc90bc048d6e9 to your computer and use it in GitHub Desktop.
Circle.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Circle : MonoBehaviour
{
[SerializeField] private GameObject prefab;
[SerializeField] private float radius = 2;
[SerializeField] private float number = 1;
private float t;
IEnumerator Start()
{
while (t < 6.28f)
{
t += 6.28f / number;
var x = Mathf.Sin(t)*radius;
var z = Mathf.Cos(t)*radius;
var spawn =Instantiate(prefab, new Vector3(x, 0, z), Quaternion.identity, transform);
var lookAngle = Mathf.Atan2(x, z) * Mathf.Rad2Deg;
spawn.transform.eulerAngles = Vector3.up * lookAngle;
yield return null;
}
}
}
@smkplus
Copy link
Author

smkplus commented Jun 23, 2020

Record_2020_06_23_23_58_56_252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment