Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

character stoping distance math

i'm trying to work out the math to give me the stopping distance and stopping time of a character. i know that if it wasn't for ground friction it would be: StopTime= Speed/braking Deceleration Stop Distance = (Speed/StopTime) / 2

but i'm finding it hard to wrap my head around how the ground friction works. it defaults to 8 and stooping times and distances don't seem to have a linear relation ship to movement speed. so i'm guess there is some exponential thing i'm not understanding. any help would be awesome, Thanks :)

Product Version: UE 4.20
more ▼

asked Jul 27 '18 at 02:45 PM in C++ Programming

avatar image

204 9 12 28

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Here is a Tutorial to how to make a wheeled vehicle in Unreal.

In reality vehicle experience 2 types of meaningful friction (static and dynamic) and materials have different friction coefficients for those cases. Here is a Wikipedia article for more information on the physics side of things. Keep in mind that all those calculations already simulated in the Unreal physics engine.

In short:

 FrictionForce = FrictionCoefficient * NormalForce

but also

 FrictionForce = ObjectMass * FrictionDeceleration


 FrictionDeceleration = FrictionCoefficient * NormalForce / ObjectMass

from this point on you get

 StopTime = Speed / FrictionDeceleration
 StopDistance = Speed * StopTime / 2

Keep in mind that the Friction Coefficient must be different when the car is sliding. (Above some maximum FrictionForce the coefficient changes) NormalForce is largely dependent on your car weight and the downforce.

If you need a full physical model of a car you will need to account for the downforce, suspension hardness, loss of friction, weight transfer between wheels, centrifugal force in turns, contact surface temperature and area (between the wheels and the road).

Some of these can and are frequently ignored in games. (temperature and weight transfer) Most of the ones that are needed (like loss of friction and down force) have simplified math models that are used in games but they are in no way simple to understand.

Happy coding :)

more ▼

answered Jul 30 '18 at 02:07 PM

avatar image

1.3k 6 5 9

avatar image r8ivy Jul 30 '18 at 03:28 PM

thanks for the reply, very interesting (and useful) stuff. still finding it hard to make sense of the character implementation of friction in relation to this however. mass doesn't effect stooping distance or time in my tests with the character movement component and its hard to pin down what the FrictionCoefficient NormalForce are in this context.

avatar image dZh0 Jul 30 '18 at 03:46 PM

Character movement component does not use physics for it's movement.

Although it has some rudimentary calculations (for gravity and acceleration) it intentionally has no friction or complex physics involved. There is a way to make a pawn use the physics engine which, however does not go through the movement component.

Check https://docs-origin.unrealengine.com/latest/INT/Videos/PLZlv_N0_O1ga0aV9jVqJgog0VWz1cLL5f/lFpXqggbUP4/index.html

avatar image r8ivy Jul 30 '18 at 04:26 PM

i'm looking to predict the stopping distance and time of the standard Character movement component. so i guess i'm looking for whatever there approximation of friction is (as the component has a number of variable associated with friction) and it doesn't stop linearly in the way it would if it had a constant deceleration force applied.

avatar image dZh0 Jul 30 '18 at 07:38 PM

In this case the you should go VERY in-depth with the character movement component.

If I were you I would start with:

 void UCharacterMovementComponent::CalcVelocity(...){..} //CharacterMovementComponent.cpp line:2986

which calls:

 bool UCharacterMovementComponent::ApplyRequestedMove(...){...} //CharacterMovementComponent.cpp line:3073

and in there is a line of code that states:

 Velocity = Velocity - (Velocity - RequestedMoveDir * VelSize) * FMath::Min(DeltaTime * Friction, 1.f);

I guess you can work your way backwards from that point but note that the file is over TEN THOUSAND lines so it wont be easy. The component has too many variables which modify the values given to these functions.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question