2024-02-02 21:03:44 +01:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2024-02-29 15:41:53 +01:00
|
|
|
[System.Serializable]
|
2024-02-02 21:03:44 +01:00
|
|
|
public class Rope
|
|
|
|
{
|
|
|
|
public List<Point> points { get ; private set; }
|
|
|
|
public List<Stick> sticks { get; private set; }
|
|
|
|
|
|
|
|
public Rope(List<Point> points, List<Stick> sticks)
|
|
|
|
{
|
|
|
|
this.points = points;
|
|
|
|
this.sticks = sticks;
|
|
|
|
}
|
2024-02-03 00:15:07 +01:00
|
|
|
|
|
|
|
public float CalculateLengthOvershoot()
|
|
|
|
{
|
|
|
|
float sum = 0f;
|
|
|
|
foreach (Stick stick in sticks)
|
|
|
|
{
|
2024-02-03 20:01:12 +01:00
|
|
|
Debug.DrawRay(stick.B.position, (stick.A.position - stick.B.position).normalized * stick.desiredLength);
|
2024-02-03 00:15:07 +01:00
|
|
|
float dist = Vector3.Distance(stick.A.position, stick.B.position);
|
|
|
|
sum += dist - stick.desiredLength;
|
|
|
|
}
|
|
|
|
return sum;
|
|
|
|
}
|
2024-02-29 20:36:48 +01:00
|
|
|
|
2024-02-02 21:03:44 +01:00
|
|
|
}
|