S
S
s2sk2018-04-03 11:05:00
C++ / C#
s2sk, 2018-04-03 11:05:00

Solver (pushing objects) of the physics engine?

There are three vectors (3D) -
acceleration
velocity
position
I update the position like this -

position += (velocity * time);
velocity += (accerelation * time);

In a collision, I get -
the normal vector of the collision
And the depth of the collision, as I understand it, can be calculated from the previous coordinates of the object before the collision, and the real ones during the collision.
Now the question is - how to push the object back and at the same time reduce its velocity based on all this data?
Now I tried to simply reflect the velocity vector relative to the collision normal vector - I got the effect of a bouncing ball back and forth (the first object I have is just a plane and the second object is a cube that I spawned at a height and now it falls (falls due to the fact that I set acceleration. Z to -9.8), the velocity vector is reflected, it rises again to a height, then falls again, and so on ad infinitum). And I need this cube to fall, push itself out of the plane (push it as far as it managed to cross the plane) and lie on the surface further (until I take into account the slope of the surface).
I know this forum is not for game development, but maybe someone will tell you in detail what and how to do.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
Griboks, 2018-04-03
@Griboks

It is necessary to enter such a parameter as elasticity . Sometimes it is called bounce material. It shows the efficiency of collision with the surface. Simply put, elasticity determines the amount of energy an object has left after a collision.
Now you have 100% elasticity - absolutely elastic bodies. But in reality this does not happen. Thus, the rebound velocity should decrease in proportion to the elasticity of the colliding bodies. Then it will decrease again and again... And then it will reach the discretization interval - the body will stop.
You also need to take into account the resistance of the environment. By itself, the speed of the body in free flight should decrease (not taking into account 9.8). This is set by viscous friction.
Shortly speaking,

  1. conduct an honest simulation
  2. or interpolate between two positions and find the one closest to the contact surfaces.

D
DTX, 2018-05-14
@DirecTwiX

You are right about elasticity. But there is to simplify, then in the event of a collision, the speed cannot be changed as
a
k = 0 - absolutely inelastic collision (the ball will stick)
k = 1 - absolutely elastic (it will jump endlessly)

D
Dmitry Alexandrov, 2018-04-03
@jamakasi666

Probably there is not enough mass parameter or at least friction, but better both at once. At worst, at least some sort of extinction coefficient of accerelation.
Now you have a completely linear world in a "spherical vacuum".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question