prototyping

This commit is contained in:
2024-09-04 18:39:41 +05:30
parent 70303078c7
commit f5e1024744
62 changed files with 29061 additions and 12386 deletions

View File

@@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AlgorithmTest : MonoBehaviour
{
public List<float> allHits = new List<float>();
public LineRenderer line;
public Vector2 offsetMultipliers = Vector2.one;
void OnDrawGizmos(){
RegenerateLines();
}
void RegenerateLines(){
Vector3[] points = new Vector3[allHits.Count];
for(int i=0; i < points.Length; i++){
points[i] = GetPosition(i);
}
line.positionCount = points.Length;
line.SetPositions(points);
}
Vector3 GetPosition(int index) {
float hitX = allHits[index];
float diff = 0;
float prevY = 0;
// Calculate diff and prevY if the index is greater than 0
if (index > 0) {
diff = allHits[index] - allHits[index - 1];
prevY = GetPosition(index - 1).y; // Recursively get the previous Y value
}
float flipSide = index % 2 == 0 ? 1 : -1;
float y = prevY + (flipSide * diff);
return new Vector3(hitX * offsetMultipliers.x, y, 0);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b4211f2cde196b14cb9d69a4879ae7cc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: