Help Is there a way to query collisions with Obi Bone? - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html) +--- Thread: Help Is there a way to query collisions with Obi Bone? (/thread-4202.html) |
Is there a way to query collisions with Obi Bone? - spikebor - 06-05-2024 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. 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) Even though I enable Collision and Particle Collision collision / Queries on my character. RE: Is there a way to query collisions with Obi Bone? - josemendez - 06-05-2024 (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, RE: Is there a way to query collisions with Obi Bone? - spikebor - 06-05-2024 (06-05-2024, 12:03 PM)josemendez Wrote: Hi!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. RE: Is there a way to query collisions with Obi Bone? - josemendez - 06-05-2024 (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. Hi, Now I understand your confusion, collision callbacks don't work the way you seem to expect. See: http://obi.virtualmethodstudio.com/manual/6.3/scriptingcollisions.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, RE: Is there a way to query collisions with Obi Bone? - spikebor - 06-05-2024 (06-05-2024, 04:48 PM)josemendez Wrote: Hi, 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? RE: Is there a way to query collisions with Obi Bone? - josemendez - 06-05-2024 (06-05-2024, 05:38 PM)spikebor Wrote: Thanks, that cleared up my confusion.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, |