I have a character that uses
rigidbody, and I am using
AddForce() to make it move. And so I do
rb.velocity = Vector3.ClampMagnitude(rb.velocity, maxSpeed) to limit diagonal speed. Yes that did worked but my problem is adding for example explosion force. So if explosion force is very high, it will still clamp the velocity of the player. What way should I use to combine
movement that limits diagonal speed and a
properly working explosion force toward the player. At least give a clue how can I do it?
My only main problem here is the way that I implemented to limit diagonal movement. I wanna improve that by not using
Vector3.ClampMagnitude() so the
AddExplosionForce() will work properly to the player. Because clamping magnitude of the player will also limit the velocity when it is affected by the explosion force.
So can anyone give a clue how can I implement to limit diagonal movement without using clamp magnitude?
I thought about normalizing the move like:
Vector3 move = transform.right * x + transform.forward * z; move = move.normalized * Time.deltaTime * moveSpeed;
But I realized I am using
AddForce(). Even though I limited the diagonal speed, it will go faster and faster because there is no maxSpeed. Help please.