#First person acceleration methods

1 messages · Page 1 of 1 (latest)

chilly aspen
#

I would set the velocity, but the velocity frame of reference will change a lot during regular gameplay (swinging platforms, fast vehicles)
Lerp felt really good for acceleration and turning, but it didn't work with rotating platforms

proven river
#

more force, lower mass

chilly aspen
proven river
#

Even more force

#

even less mass

#

more torque

#

smaller moment of inertia

#

that's the only way when doing realistic force based physics to increase acceleration

#

Or, like I said, just use ForceMode.Acceleration and unity will do the math for you

proven river
#

Also it's possible you have some stuff in your code currently that is overwriting velocity etc.. and cancelling this stuff out.

chilly aspen
proven river
#

You just define how quickly you want to accelerate

proven river
#

if you want to accelerate at 10 m/s^2, then you do cs rb.AddForce(10 * direction, ForceMode.Acceleration);

#

in FixedUpdate

#

to determine if the input vector is opposite the direction of the current velocity you can do something like:

if (Vector3.Dot(transformedInputVector, rb.velocity) < 0) {
  // input is generally against the current direction
}```
#

Basically you've got to have a really good understanding of vector math and the basic newtonian physics to get something that feels quite good.

chilly aspen
#

Okay, actually I think drag and low mass solved the sliding problem, but how do I enforce a max velocity based on the surface the player is grounded to?

proven river
#

then use cs rb.velocity = Vector3.ClampVelocity(rb.velocity, maxVelocityForSurface);

#

(or replace raycast with however you're doing your grounded check)

chilly aspen
#

Since the object is rotating, I have to somehow get the linear velocity of the contact point

proven river
#

If so you can use:

chilly aspen
#

Not sure if it'll be scaleable though, since eventually my planets won't be small enough to use rigidbody rotation. By then I'll have a sort of analog to that method though