/// <summary> /// Calculates the verlet acceleration using a point and a time delta /// </summary> /// <param name="point"> point to calculate for</param> /// <param name="dt"> delta time</param> private void Verlet(ref VerletLinePoint point, float dt) { Vector3 temp = point.Pos; point.Pos += ((point.Pos - point.OldPos) * _dampening) + (point.Acceleration * dt * dt); point.OldPos = temp; }
private void InitRope() { Vector3 pointPosition = _floaterPos.position; for (int i = 0; i < _resolution; i++) { _points[i] = new VerletLinePoint(pointPosition, Physics.gravity); pointPosition.y -= SECTION_LENGTH; } }
private void ConstrainLine(ref VerletLinePoint p1, ref VerletLinePoint p2, float restLength) { Vector3 delta = p2.Pos - p1.Pos; float deltaLength = delta.magnitude; float diff = (deltaLength - restLength) / deltaLength; p1.Pos += delta * diff * SECTION_LENGTH; p2.Pos -= delta * diff * SECTION_LENGTH; }