The question is answered, right answer was accepted
Calculate max velocity.magnitude
Hello guys, first of all, sorry if i made mistakes, english is not my native language, so if you don't understand tell me, i will try to re-explain it :)
I try to calculate the maximum speed of my player, in the purpose to deal damage when he collides with another object, according to a percentage equal to : (his current speed/maximum speed).
To have the speed, i think to use velocity.magnitude, but i didn't find how to calculate the maximum magnitude of my player.
My player have a rigidbody, with a mass of 50 and a drag of 3. To make my player move, i use Input.GetAxis(X) and Input.GetAxis(Y) i put them in a Vector3 name movement, then i make myPlayerRigidbody.AddForce(movement x Speed, forceMode.Force)
Speed is a public int, currently set to 2500.
Thanks for your help, i already look at a lot of topic yesterday for many hours, and i didn't find a working manner to do what i want.
So, what is the question? You want to deter$$anonymous$$e the maximum speed?
If so, usually, you'll just pick an arbitrary number. But if you want to measure it, I would just print out the velocity.magnitude every frame, get up to speed in the game, and see what is printed.
Yes i want to deter$$anonymous$$e the maximum speed, but with calculation, because if i change drag of mass of my player it will change the max speed
Then you're going to need to run the physics calculations yourself, after quite a bit of research.
Alternately, you can just use flat limits, rather than as a percentage of speed; in which case you don't need to know the absolute maximum.
Follow this Question
Related Questions
Change Camera's size relative to player's speed 0 Answers
Top Down Character - Face direction of movement? 0 Answers
Object Player Movement stops working after Restarting Unity 0 Answers
How to move 3 players at the same time in V form,How to move 3 characters in the same time in V form 0 Answers
Character continues moving when locked onto an enemy 1 Answer