This commit is contained in:
Gerard Gascón 2025-04-24 17:37:25 +02:00
commit 341a877b4a
2338 changed files with 1346408 additions and 0 deletions

View file

@ -0,0 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WeightedLocation : MonoBehaviour
{
[System.Serializable]
public struct WeightedTarget
{
public Transform t;
public float weight;
}
public List<WeightedTarget> targets;
private void Update()
{
transform.position = Vector3.zero;
Vector3 pos = Vector3.zero;
Vector3 pivot = targets[0].t.position;
float factor = 0;
foreach(WeightedTarget t in targets)
{
pos += t.t.position * t.weight;;
factor += t.weight;
}
pos /= (factor);
transform.position = pos;
}
}