summaryrefslogtreecommitdiffhomepage
path: root/Assets/Scripts/Graph.cs
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2022-12-05 23:17:56 -0500
committerrealtradam <[email protected]>2022-12-05 23:17:56 -0500
commit6b7f05daefae6e127d3fc5c75ca725c9b1478bf1 (patch)
treee98f1846aeae979e4e4ec9b361d19b7d8d40b940 /Assets/Scripts/Graph.cs
downloadUnityDancingGraph-6b7f05daefae6e127d3fc5c75ca725c9b1478bf1.tar.gz
UnityDancingGraph-6b7f05daefae6e127d3fc5c75ca725c9b1478bf1.zip
init
Diffstat (limited to 'Assets/Scripts/Graph.cs')
-rw-r--r--Assets/Scripts/Graph.cs45
1 files changed, 45 insertions, 0 deletions
diff --git a/Assets/Scripts/Graph.cs b/Assets/Scripts/Graph.cs
new file mode 100644
index 0000000..1486990
--- /dev/null
+++ b/Assets/Scripts/Graph.cs
@@ -0,0 +1,45 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class Graph : MonoBehaviour
+{
+ [SerializeField]
+ Transform pointPrefab;
+
+ [SerializeField, Range(10, 100)]
+ int resolution = 10;
+
+ Transform[] points;
+
+ void Awake() {
+ points = new Transform[resolution];
+ float step = 8f / points.Length;
+ for(int i = 0; i < points.Length; i++) {
+ Transform point = Instantiate(pointPrefab);
+ points[i] = point;
+ Vector3 position = pointPrefab.localPosition;
+ point.SetParent(transform, false);
+ position.x = (i + 0.5f) * step - 4f;
+ point.localPosition = position;
+ }
+ }
+
+ // Start is called before the first frame update
+ void Start()
+ {
+
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
+ float time = Time.time;
+ for(int i = 0; i < points.Length; i++) {
+ Transform point = points[i];
+ Vector3 position = point.localPosition;
+ position.y = Mathf.Sin(Mathf.PI * (position.x + time));// * position.x * position.x;
+ point.localPosition = position;
+ }
+ }
+}