fgm24/Assets/Scripts/Rope/Rope.cs

27 lines
716 B
C#
Raw Permalink Normal View History

2024-02-02 21:03:44 +01:00
using System.Collections.Generic;
using UnityEngine;
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-02 21:03:44 +01:00
}