Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Weird physics behavior when using AddForce and changing scale of Solver
#3
(07-12-2020, 10:57 AM)josemendez Wrote: Hi there,

I assume your solver does not move at all. While the solver is shrinking, you're propelling the softbody forward using a force (which is expressed and applied in the solver's local space).

Think about it: the behavior you describe is 100% correct and to be expected. Try picturing what happens when you scale a transform down, and the child transforms are not exactly at the parent's origin: they will get scaled down towards the parent. The same happens with actors inside a solver:

[Image: eoGG7Pd.gif]

As long as the force you're applying displaces the softbody further away from the solver's origin than the scaling does, the softbody will move forward. At some point though, both displacements will even each other out (as the force is also scaled down with the solver, since it's applied in solver space), and shortly after that, the displacement due to scaling will be larger than the one due to the force:

[Image: BZwiwb5.gif]

The result is that the softbody moves forward at first, but progressively decelerates and then begins moving towards the solver's origin.

So this setup does not do what you were expecting. I don't know the details of your use case, though. If you could describe what you're looking for in detail, I would be able to suggest alternatives. The simplest thing that comes to mind is converting your force from world space to solver space before applying it. This way, as the solver gets scaled down, the force will be scaled up and compensate for it.
Thanks so much for the detailed response, it makes a lot of sense.

I like your idea of converting the force from world space to solver space. I'm not quite sure how to approach it, though. Currently, we are applying a force to the softbody in the solver with ObiActor.AddForce and a ForceMode of acceleration:
Code:
_softbody.AddForce(Vector3.forward * _acceleration, ForceMode.Acceleration);
_acceleration is just a float set to 3.0f.

Any ideas?
Reply


Messages In This Thread
RE: Weird physics behavior when using AddForce and changing scale of Solver - by picross - 10-12-2020, 08:51 PM