22-11-2022, 08:41 AM
(This post was last modified: 22-11-2022, 08:44 AM by josemendez.)
(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