#First person acceleration methods
1 messages · Page 1 of 1 (latest)
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
Like I said before, if you want to accelerate faster: #💻┃code-beginner message
more force, lower mass
I have tried, I still can't change directions fast enough
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
You have to not be afraid of doing things like "if the user wants to turn around, use a greater amount of force than just normal forward acceleration"
Also it's possible you have some stuff in your code currently that is overwriting velocity etc.. and cancelling this stuff out.
That's kinda my original question, I don't know the calculation for that vector
You just define how quickly you want to accelerate
Nah, it's a fresh project
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.
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?
raycast to the surface to determine what it is
then use cs rb.velocity = Vector3.ClampVelocity(rb.velocity, maxVelocityForSurface);
(or replace raycast with however you're doing your grounded check)
It's a rotating sphere lol
Since the object is rotating, I have to somehow get the linear velocity of the contact point
Does the rotating object have a Rigidbody, and is it rotating with an angularVelocity?
If so you can use:
Woah, just like that, my problems are solved
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