- Home /
How to Detect Collision, Calculate Velocity+Mass, Apply Damage
I'm trying to build a puzzle that features objects that fall in a pattern and traps of the classic sort: spears that shoot from holes in walls. There are various other ridgidbody-prefabs likeke these I want to hurt the player, and I'm even trying ridgidbody bullets. instead of calculating proportionate damage for each of these, I'd like to calculate their velocity and mass, and apply a proportional amount of damage to the player. How do I do this? I'm beginning to learn javascript, but this is slightly out of my scope. I know that I should use "onCollision" in conjunction with GetComponent.ridgidbody.something and calculate them together with a coefficient for conversion between damage points and mass x velocity using mathF, but I don't know how to use all of these together. I guess, also, that if the collision is not with a ridgidbody, but, say, a mesh collider, that they player could calculate it's own mass and velocity, and apply damage there, too. I can't imagine someone else hasn't already done something that approximates this, and I can adapt a script that does something close to this to what I need, if anyone has one. Thanks!
Your answer
Follow this Question
Related Questions
Cannot detection collision 1 Answer
Damage by collision with ridgidbodies 1 Answer
Damage on collision problems... 0 Answers
Player take damage on collision with AI 1 Answer
Character controller mess up damage 3 Answers