15-12-2023, 08:09 PM
(14-12-2023, 12:04 PM)josemendez Wrote: Could you elaborate a bit? Do you mean a label that shows the amount of particles in the blueprint?Exactly! I added an 'Int' simply for convenience, mainly because I was trying to find a configuration that gave me the best balance between performance and visuals.
If so, a simple workaround is to hit the "invert selection" button in blueprint edit mode to select all particles, then look at the amount of selected particles. But yeah, we can add an info field with the amount of particles.
On the other hand, I've been trying to generate everything at runtime like my original code. I noticed that the method for binding has changed, and i cant make it work correctly. (I initially deactivate the game object with the skinned mesh, add the soft body component and the skinner, and then reactivate the game object and make it a child of the solver). In the previous version, it worked without any problems. Am I missing something? Or perhaps it's no longer possible to generate them at runtime?"
Code:
var Skinner = SkinnedMesh.gameObject.AddComponent<ObiSoftbodySkinner>();
var SoftBody = SkinnedMesh.gameObject.AddComponent<ObiSoftbody>();
var Blueprint = ScriptableObject.CreateInstance<ObiSoftbodySurfaceBlueprint>();
Blueprint.inputMesh = SkinnedMesh.sharedMesh;
Blueprint.skeleton = SkinnedMesh.rootBone.gameObject;
Blueprint.rootBone = SkinnedMesh.rootBone;
Blueprint.surfaceResolution = SurfaceResolution;
Blueprint.surfaceSamplingMode = SurfaceMode;
Blueprint.volumeResolution = VolumeResolution;
Blueprint.volumeSamplingMode = VolumeMode;
Blueprint.GenerateImmediate();
SoftBody.softbodyBlueprint = Blueprint;
Skinner.softbody = SoftBody;
Skinner.customSkinMap = Blueprint.defaultSkinmap;
Skinner.Bind();
If I add the Particle Renderer, I can see that the particles are generated correctly and deform properly when moving the bones. However, the mesh glitch completely, so I assume I'm missing something when I do the binding or maybe the skinmap?.