I’m just starting to play around with collisions, I have two objects with RigidBodys that have frozen positions and directions being moved by transform.Translate functions, and the player-controlled object has this script on it.
void OnCollisionEnter(Collision info){
string log = "Collider: " + info.collider.ToString() + "
Contacts: " + info.contacts.ToString() + "
frictionForce: " + info.frictionForceSum +
"
ImpactForce: " + info.impactForceSum + "
RelativeVelocity: " + info.relativeVelocity;
Debug.Log(log);
}
The trouble is, no matter what, that returns:
Collider: t_fort(Clone) (UnityEngine.CapsuleCollider)
Contacts: UnityEngine.ContactPoint[]
frictionForce: (0.0, 0.0, 0.0)
ImpactForce: (0.0, 0.0, 0.0)
RelativeVelocity: (0.0, 0.0, 0.0)
UnityEngine.Debug:Log(Object)
PlayerTileMovement:OnCollisionEnter(Collision) (at Assets/PlayerTileMovement.cs:34)
The zeros aren’t helpful. I’m trying to write it so that if the collision is slow and gentle enough, the objects will stick (via a different script not yet written) but if it’s too fast/violent they should bounce off each other.
Does anyone have any idea what’s going wrong here?