hello. i’m working on a racing game right now and when my car enter in collision with a wall he dies or else he gets friction and the speed is decremented. The problem is that those collisions aplly to the other cars two when I hit them but I dont want my cars to destroy each other when they collide I want them only to bump each other.
here is my code
void OnCollisionStay(Collision death)
{
if (death.contacts.Length > 0)
{
if (Vector3.Dot(death.contacts[0].normal, floor) < treshold)
{
if (Vector3.Dot(death.contacts[0].normal, moveDirection.normalized) <= fricTreshold currentSpeed >= 20)
{
gameObject.SetActiveRecursively(false);
currentSpeed = 0;
Invoke("Respawn", 2);
}
else
{
currentSpeed *= forcedBrake;
}
}
}
}
is it better to use a tag or something else?