Trying to get collisionInfo for two simultaneous collisions.
I’m new to this so bear with me.
I want to eventually be able to compile the GetContact.normal
so that I may take the mean of the normals for each contact point for all the collisions.
The code below is as close as I’ve managed to get but when adding the collision ‘other’ to the list, every time another OnCollisionEnter
occurs the value of ‘other’ in the list is also overwritten.
The result is the gameObject.name of the last collision is called again for however many objects are currently being collded with.
Here’s where I’m at so far:
private List<Collision> collisionsInfo = new();
public void OnCollisionEnter ( Collision other )
{
collisionsInfo.Add(other);
foreach (Collision col in collisionsInfo)
{
Debug.Log(col.gameObject.name);
}
}
My goal is to somehow compile all the collision normals (of at least two concurrent collisions) at any one time (when key is pressedDown
) and use them.
If there is a way to make this code work, or to use a different method that solves my issue, that would be fantastic! Thank you.