Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Is there a way to query collisions with Obi Bone?
#1
I want to detect collisions with this character (which has nothing on him other than Obi bone)
Can it be done, or he should have Collider? I think Obi Bone or not, it has particles under it as all Obi things, so I can query its collisions with my character (my character has Obi Collider)
I want to debug the impulse.

[Image: AfR6o6v.png]

The Golem can contact and push my character back, but this code (subscribed to character's solver.OnCollision event) returns no collisions.
Code:
        void Solver_OnCollision(object sender, ObiSolver.ObiCollisionEventArgs e)
        {
            foreach (Oni.Contact contact in e.contacts)
            {
                collisionsImpulse += contact.normalImpulse;
            }
        }

Even though I enable Collision and Particle Collision collision / Queries on my character.
Reply
#2
(06-05-2024, 12:00 PM)spikebor Wrote: Can it be done, or he should have Collider? I think Obi Bone or not, it has particles under it as all Obi things, so I can query its collisions with my character (my character has Obi Collider)

Hi!

It's not clear to me whether your character has a collider or not. You ask whether it should have a Collider, but then you mention it has a ObiCollider?

ObiColliders are intended to expose Colliders to ObiSolvers. So if you have a Collider that you want Obi to detect collisions against, it must also have a ObiCollider. This included collision callbacks like the one you've subscribed to, so yes: your character must have a Collider (and ObiCollider) for particles to collide against it, and for callbacks to return any contacts.

kind regards,
Reply
#3
(06-05-2024, 12:03 PM)josemendez Wrote: Hi!

It's not clear to me whether your character has a collider or not. You ask whether it should have a Collider, but then you mention it has a ObiCollider?

ObiColliders are intended to expose Colliders to ObiSolvers. So if you have a Collider that you want Obi to detect collisions against, it must also have a ObiCollider. This included collision callbacks like the one you've subscribed to, so yes: your character must have a Collider (and ObiCollider) for particles to collide against it, and for callbacks to return any contacts.

kind regards,
Yes, my character can collide with this Golem, she gets pushed back when received the attack. The setup is:
character: Obi Collider , Collider, Obi Solver, Obi Fixed Updater.
The Golem: Obi solver , obi fixed updater, Obi bone.
The collision happened between my character capsule and the Obi Bone of Golem.
I just wonder if I can receive collision events with more info so I can debug the impulse?
With the same code, I can receive the collision events between a softbody character with a collider, but this setup can not receive the event, even though my character can contact with the Golem's Obi bone.

Further inspection: Test the Golem with just a Cube with Obi Solver + Obi Fixed Updater + Obi Collider + Collider + Rigidbody + Obi Rigidbody.

Result: the Golem's solver shows its Particles 51, Simplices 50, and Contacts 22, while the Cube's Solver shows nothing
This means we can receive the Collisions event on the Golem which has particles, but not on the Cube which has no particle.

Can the system send the collision event to the Cube (contact receiver with no Obi particle) too? like Unity physics, the collision events send to every collider in that contact.
Reply
#4
(06-05-2024, 03:19 PM)spikebor Wrote: With the same code, I can receive the collision events between a softbody character with a collider, but this setup can not receive the event, even though my character can contact with the Golem's Obi bone.
[...]
This means we can receive the Collisions event on the Golem which has particles, but not on the Cube which has no particle.

Hi,

Now I understand your confusion, collision callbacks don't work the way you seem to expect. See:
http://obi.virtualmethodstudio.com/manua...sions.html

Quote:Obi does not work with the default Unity collision callbacks (OnCollisionEnter,OnCollisionExit,OnCollisionStay...) because of performance and flexibility reasons. Instead, the ObiSolver component can provide a list of all contacts generated during the current frame. You can then iterate this list of contacts and perform any custom logic you need.

When you subscribe to OnCollision, you get a list of all contacts between particles and colliders in the solver. For each individual contact, you can tell the specific particle and collider involved in that contact. This allows you to process the contacts in parallel should you need to, which is a lot more efficient than having them scattered across function calls to multiple objects like Unity does, specially if you have thousands of contacts every frame.


(06-05-2024, 03:19 PM)spikebor Wrote: Can the system send the collision event to the Cube (contact receiver with no Obi particle) too? like Unity physics, the collision events send to every collider in that contact.

The system will send the collision event to whatever object(s) you subscribe to the OnCollision event. So typically you subscribe just one object (doesn't matter which one) to OnCollision, then process all contacts just once and perform whatever logic you need depending on the particle/collider involved in each contact.


kind regards,
Reply
#5
(06-05-2024, 04:48 PM)josemendez Wrote: Hi,

Now I understand your confusion, collision callbacks don't work the way you seem to expect. See:
http://obi.virtualmethodstudio.com/manua...sions.html


When you subscribe to OnCollision, you get a list of all contacts between particles and colliders in the solver. For each individual contact, you can tell the specific particle and collider involved in that contact. This allows you to process the contacts in parallel should you need to, which is a lot more efficient than having them scattered across function calls to multiple objects like Unity does, specially if you have thousands of contacts every frame.



The system will send the collision event to whatever object(s) you subscribe to the OnCollision event. So typically you subscribe just one object (doesn't matter which one) to OnCollision, then process all contacts just once and perform whatever logic you need depending on the particle/collider involved in each contact.


kind regards,

Thanks, that cleared up my confusion.
I understand now, so the system can only output contacts in its solver (which has any type of ObiActor). In case of the Cube which is just an Obi Collider it can't know the attacker who added force on it, since it cannot query any contacts in its solver.
Is there any workaround for this?
Reply
#6
(06-05-2024, 05:38 PM)spikebor Wrote: Thanks, that cleared up my confusion.
I understand now, so the system can only output contacts in its solver (which has any type of ObiActor). In case of the Cube which is just an Obi Collider it can't know the attacker who added force on it, since it cannot query any contacts in its solver.
Is there any workaround for this?
Hi!

No, that’s not how it works either: the system can output contacts in *any* object, you just need to subscribe that object to the solver’s OnCollision event.

The callback you get for that event contains a list of 
*all* contacts between the particles in that solver and *all* ObiColliders in the scene. Each contact contains a reference to a collider and a reference to a particle in the solver. So for each contact you can know the particle that collided, the actor it belongs to, and which collider it collided against.

There’s no need for a collider to be inside a solver or have a reference to a solver for contacts to work: *all* ObiColliders in the scene are considered by all solvers.

See the manual for sample code snippets for all of the above, let me know if you need further help.

Kind regards,
Reply