Files
aibis-dream/Assets/Scripts/FixSystem/Line/VerletParticle.cs
T
2024-08-28 17:04:13 +08:00

32 lines
736 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VerletParticle
{
public Vector3 position;
public Vector3 previousPosition;
public bool isLocked;
public VerletParticle(Vector3 position)
{
this.position = position;
this.previousPosition = position;
this.isLocked = false;
}
public void ApplyForce(Vector3 force)
{
Vector3 temp = position;
position += position - previousPosition + force;
previousPosition = temp;
}
public void UpdatePosition(float deltaTime)
{
Vector3 temp = position;
position += (position - previousPosition) * deltaTime;
previousPosition = temp;
}
}