Hello,
I’m trying to get a collider’s closest point to a gameobject with a capsule collider
When the capsule intersects the collider, I get a point, but that point doesn’t move when the collider move. How do I update the collider.Closestpoint?
Relevant code here:
public class Collision : MonoBehaviour
{
List<Vector3> posContacts = new List<Vector3>();
List<Collider> cContacts = new List<Collider>();
void OnTriggerEnter(Collider other)
{
cContacts.Add(other);
if(posContacts.Count != 0)
{
posContacts.Add(cContacts[cContacts.Count - 1].ClosestPoint(transform.position));
}
else
{
posContacts.Add(cContacts[0].ClosestPoint(transform.position));
}
}
void FixedUpdate()
{
for(int i = 0; i < posContacts.Count - 1; i++)
{
posContacts _= cContacts*.ClosestPoint(transform.position);*_
}
}
}
The update part doesn’t work. Can you help me? Thanks.