Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Collision bug
#1
Bug 
Im developing a game about splitting softbodies. When a player clicks on a softbody Im destroying it and spawning 2 more smaller softbodies. The problem is that when im doing this some softbodies just dont collide with each other at all like they have some kind of collider filter. I've tried:
 1. Increasing solver substeps, increasing Particle Collision iteration count
 2. Spawning and destroying softbodies with some delay
 3. Spawning and destroying softobodies in solver.OnPrepareFrame
 4. Increasing particle radius,
and still nothing.

Obi Softbody 6.5.4
Unity 2022.3.13f

im not sure how to insert videos here so only screenshot for now
   
Reply
#2
(15-04-2024, 11:21 AM)bozdo Wrote: just dont collide with each other at all like they have some kind of collider filter.

Hi!

Have you checked whether they actually do have a filter?

How are you creating and spawning these smaller softbodies? Could you share your code for this?
Reply
#3
(15-04-2024, 12:05 PM)josemendez Wrote: Hi!

Have you checked whether they actually do have a filter?

How are you creating and spawning these smaller softbodies? Could you share your code for this?
Code:
    public void Spawn(JellyObject prefab, Vector3 position, Quaternion rotation, Action<JellyObject> OnSpawn = null)
    {
        instances++;
        int id = instances;

        //solver.OnEndStep += SpawnJelly;
        solver.OnPrepareFrame += SpawnJelly;

        void SpawnJelly(ObiSolver solver)
        {
            solver.OnPrepareFrame -= SpawnJelly;
            JellyObject jelly = Instantiate(prefab, position, rotation);
            jelly.transform.SetParent(jellyParent);

            spawnedObjects.Add(jelly);
            SetRandomColor(jelly);

            jelly.spawnID = id;

            if (jelly.Softbody)
            {
                //solver.AddActor(jelly.actor);
            }
            OnSpawn?.Invoke(jelly);
        }
    }
Reply
#4
(15-04-2024, 12:38 PM)bozdo Wrote:
Code:
    public void Spawn(JellyObject prefab, Vector3 position, Quaternion rotation, Action<JellyObject> OnSpawn = null)
    {
        instances++;
        int id = instances;

        //solver.OnEndStep += SpawnJelly;
        solver.OnPrepareFrame += SpawnJelly;

        void SpawnJelly(ObiSolver solver)
        {
            solver.OnPrepareFrame -= SpawnJelly;
            JellyObject jelly = Instantiate(prefab, position, rotation);
            jelly.transform.SetParent(jellyParent);

            spawnedObjects.Add(jelly);
            SetRandomColor(jelly);

            jelly.spawnID = id;

            if (jelly.Softbody)
            {
                //solver.AddActor(jelly.actor);
            }
            OnSpawn?.Invoke(jelly);
        }
    }

No need to to do this in solver.OnPrepareFrame.

To add an actor to a solver, you just parent it under the solver transform (at any nesting level). Never call solver.AddActor manually unless you're 100% sure what you're doing, as it assumes all other conditions for the simulation to take place are met (both actor and solver have been initialized, the actor has a reference to the solver and it is below it in the scene hierarchy, etc).

kind regards
Reply
#5
(15-04-2024, 01:19 PM)josemendez Wrote: No need to to do this in solver.OnPrepareFrame.

To add an actor to a solver, you just parent it under the solver transform (at any nesting level). Never call solver.AddActor manually unless you're 100% sure what you're doing, as it assumes all other conditions for the simulation to take place are met (both actor and solver have been initialized, the actor has a reference to the solver and it is below it in the scene hierarchy, etc).

kind regards
it's doesnt do much
updated code
Code:
public void Spawn(JellyObject prefab, Vector3 position, Quaternion rotation, Action<JellyObject> OnSpawn = null)
    {
        instances++;
        int id = instances;

        JellyObject jelly = Instantiate(prefab, position, rotation);
        jelly.transform.SetParent(jellyParent);

        spawnedObjects.Add(jelly);
        SetRandomColor(jelly);

        jelly.spawnID = id;

        OnSpawn?.Invoke(jelly);
    }
Reply
#6
(15-04-2024, 02:13 PM)bozdo Wrote: it's doesnt do much
updated code
Code:
public void Spawn(JellyObject prefab, Vector3 position, Quaternion rotation, Action<JellyObject> OnSpawn = null)
    {
        instances++;
        int id = instances;

        JellyObject jelly = Instantiate(prefab, position, rotation);
        jelly.transform.SetParent(jellyParent);

        spawnedObjects.Add(jelly);
        SetRandomColor(jelly);

        jelly.spawnID = id;

        OnSpawn?.Invoke(jelly);
    }

As per my first post: have you checked the collision filters, in case they’re set to not collide with each other?

These are set on a per-particle basis on the blueprint. I assume you’ve created the blueprint in-editor, then assigned it to the prefab instantiated by this code?
Reply
#7
(15-04-2024, 03:30 PM)josemendez Wrote: As per my first post: have you checked the collision filters, in case they’re set to not collide with each other?

These are set on a per-particle basis on the blueprint. I assume you’ve created the blueprint in-editor, then assigned it to the prefab instantiated by this code?
I'm not doing anything with collision filters. In blueprints, the category of every particle is set to 1 and Collides with everything. It's true for all blueprints i'm using. Also in my first screenshot you can see that big softbody collides with one smaller softbody and doesnt collide with the other one, but they both have the same blueprint.
   
Reply
#8
(15-04-2024, 03:43 PM)bozdo Wrote: I'm not doing anything with collision filters. In blueprints, the category of every particle is set to 1 and Collides with everything. It's true for all blueprints i'm using. Also in my first screenshot you can see that big softbody collides with one smaller softbody and doesnt collide with the other one, but they both have the same blueprint.

Just to rule out basic setup issues: are all these softbodies simulated by the same solver? (Solvers don’t interact with each other)

In that case, there’s no obvious reason why they shouldn’t collide with each other. Would it be possible for you to send this project (or a similar one that reproduces the same issue) to support(at)virtualmethodstudio.com so that I can take a closer look?

Kind regards,
Reply
#9
(15-04-2024, 04:06 PM)josemendez Wrote: Just to rule out basic setup issues: are all these softbodies simulated by the same solver? (Solvers don’t interact with each other)

In that case, there’s no obvious reason why they shouldn’t collide with each other. Would it be possible for you to send this project (or a similar one that reproduces the same issue) to support(at)virtualmethodstudio.com so that I can take a closer look?

Kind regards,
Sure! Let me prepare this project
Reply