Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scaling Softbody / Solver Updates
#2
(21-11-2022, 10:13 PM)nakoustix Wrote: I already discovered that it's possible to scale a softbody via the scaling solver way.
However, when I do this, many world coordinates change and (for instance) a camera script following the softbody introduces glitches.
Is there a better way to scale (increasingly, grow) softbodies or how do I compensate the glitches of the solver updates?

Hi!

If you scale (or rotate, or translate) the solver, all positions of particles inside of it will need to be converted from local space to world space (or more precisely, to the space your other scripts expect to use). This is not just some quirk exclusive to Obi,  the same would happen to regular GameObjects parented to another transform: their local and world space coordinates cease to be the same, and you need to convert back and forth.

Unity's Transform class has built-in methods to convert from local to world space and vice-versa, since it's a basic operation that gets used very often:

To transform a position from local to world (this is what you need to use to convert the position the camera follows):
https://docs.unity3d.com/ScriptReference...Point.html

To transform a vector from local to world:
https://docs.unity3d.com/ScriptReference...ector.html

To transform a position from world to local:
https://docs.unity3d.com/ScriptReference...Point.html

To transform a vector from world to local:
https://docs.unity3d.com/ScriptReference...ector.html

let me know if you need further help,

kind regards
Reply


Messages In This Thread
Scaling Softbody / Solver Updates - by nakoustix - 21-11-2022, 10:13 PM
RE: Scaling Softbody / Solver Updates - by josemendez - 22-11-2022, 08:41 AM