#Assuming a somewhat realistic simulation

1 messages · Page 1 of 1 (latest)

karmic venture
#

Then you apply the maximum engine force in the opposite direction of the motion until v = 0. If you stop firing the engine at exactly the right time, you hit 0 perfectly

#

there is no "correct" amount of force you'd apply to reach 0 velocity. Any amount of force (big or small) will get you there

golden sapphire
#
var velo = rb.velocity;
var v2 = velo.sqrMagnitude;
if (v2 > 0.01f)
{
    var v = velo.magnitude;
    var m = rb.mass;
    var ddt = 2 * v * m;
    var ddtAmp = ddt * ddt; * 59f; // amplified 59f because we're targeting 60fps so we can amplify the applied force
    var jpf2 = jpf * jpf;
    if (ddt2 > jpf2)
    {
                    
    }
} else
{
    rb.velocity = Vector3.zero;
}```
#

Also I set Time.maximumDeltaTime = 1f / 60f;

#

I'm trying to simulate a jetpack bring the astronaut to a complete stop.

karmic venture
#

you should not multiply your force by anything depending on your framerate

golden sapphire
karmic venture
golden sapphire
#

I'm trying to simulate a jetpack bring the astronaut to a complete stop.
Like when there is no input I want a damping effect.

karmic venture
#

if you start messing with stuff based on framerate, you'll be undoing that

golden sapphire
karmic venture
#
if(rb.velocity.sqrMagnitude > 0.01f)
{
  rb.AddForce(dampingForce * (-rb.velocity.normalized));
}
else
{
  rb.velocity = 0;
}
golden sapphire
karmic venture
golden sapphire
#

Or it does because AddForce account for it.

karmic venture
#

you don't need to do anything for dt or t

#

and you should not

golden sapphire
#

I disagree

karmic venture
#

okay, you're welcome to do whatever you like

golden sapphire
#

Because the formula in the docs DECREASES the F

karmic venture
#

yes, it multiplies it by the fixed timestep

#

which is what it is SUPPOSED to do

golden sapphire
#

But if we have more available

karmic venture
#

that number is like 0.2

#

more what available?

golden sapphire
#

thrust

#

or f

karmic venture
#

🤦‍♂️

golden sapphire
#

What?

karmic venture
#

you literally passed in the amount of force to use

golden sapphire
#

Force isn't time based?

karmic venture
#

acceleration = force * time

#

in this case

#

time is Time.fixedDeltaTime

#

which is small

golden sapphire
#

I'm not trying to be diffacult here I swear I'm literally trying to understand.

karmic venture
#

so the acceleration is smaller than the force

#

because the timestep is small

golden sapphire
#

So we apply more F

#

if available

karmic venture
#

you decide what force is available

#

you should pass in whatever you think is available

#

that has nothing to do with AddForce or the time step or anything

#

that's just what number you decide is the amount of force the thing can output

#

and definitely has nothing to do with framerate

golden sapphire
#

So lets imagine an "engine" with a max force of 1 in all directions

karmic venture
#

then you pass 1 into AddForce

#

the end

golden sapphire
#

What is v

#

velocity

karmic venture
#

I don't know where you got that equation

#

it is nonsense

golden sapphire
#

It's supposed to be P

karmic venture
#

it has nothing to do with the physics you're asking about

golden sapphire
#

momentum?

karmic venture
#

v*m is momentum

#

but that has nothing to do with what you're asking about

golden sapphire
#

Okay let me do some more reading. Is it okay if I ping you later?

karmic venture
#

please dont

golden sapphire
#

diick