Posts: 7
Threads: 3
Joined: Jan 2022
Reputation:
0
15-04-2024, 11:21 AM
(This post was last modified: 15-04-2024, 11:26 AM by bozdo.)
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
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
15-04-2024, 12:05 PM
(This post was last modified: 15-04-2024, 12:06 PM by josemendez.)
(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?
Posts: 7
Threads: 3
Joined: Jan 2022
Reputation:
0
(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);
}
}
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(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
Posts: 7
Threads: 3
Joined: Jan 2022
Reputation:
0
15-04-2024, 02:13 PM
(This post was last modified: 15-04-2024, 02:18 PM by bozdo.)
(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);
}
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(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?
Posts: 7
Threads: 3
Joined: Jan 2022
Reputation:
0
15-04-2024, 03:43 PM
(This post was last modified: 15-04-2024, 03:51 PM by bozdo.)
(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.
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
15-04-2024, 04:06 PM
(This post was last modified: 15-04-2024, 04:09 PM by josemendez.)
(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,
Posts: 7
Threads: 3
Joined: Jan 2022
Reputation:
0
(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
|