im trying to calculate the force an object gets hit by when i swing a bat at it or throw it against the wall im not sure why this dosent work as it has worked in the past for me
void OnCollisionEnter(Collision collision) {
float otherMass;
if (collision.rigidbody) {
otherMass = collision.rigidbody.mass;
}
else{
otherMass = 1000;
float force = collision.relativeVelocity * otherMass;
if (force > 1){
print("force = "+force);
}
}
}
i never used to get this error
Cannot implicitly convert type `UnityEngine.Vector3' to `float'
but now i do and its pointing to the float force part of the script
↧