• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
This question was closed May 22, 2016 at 12:22 PM by n_armelle for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by n_armelle · May 15, 2016 at 09:05 AM · movementplayermaxmagnitude

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.

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image n_armelle · May 20, 2016 at 04:25 PM 0
Share

I still need help please ^^

avatar image FortisVenaliter · May 20, 2016 at 04:28 PM 1
Share

So, what is the question? You want to determine 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.

avatar image n_armelle FortisVenaliter · May 20, 2016 at 04:39 PM 0
Share

Yes i want to determine the maximum speed, but with calculation, because if i change drag of mass of my player it will change the max speed

avatar image FortisVenaliter n_armelle · May 20, 2016 at 05:29 PM 0
Share

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.

0 Replies

  • Sort: 

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

64 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Using Raycast for player movement... 0 Answers

How do I make a surface move a player forward? 1 Answer

I can't move my player in a fps? 1 Answer

Player only moves when the key is pressed, not when it's held. 0 Answers

Is there a way to move a player with forces only if the mouse has changed position? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges