Help Detect specific rope collision. - 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 Detect specific rope collision. (/thread-2521.html) |
RE: Detect specific rope collision. - josemendez - 19-11-2020 (19-11-2020, 02:24 PM)canerozdemir Wrote: Oh, I missed that one. However, the outcome is still the same. FPS drop happens and the game becomes unplayable. This is the code: Well, you're writing the collider name to console once per contact, no wonder performance goes down the drain . Writing to the console is extremely slow. Remove the print() line and it should run acceptably fast. Edit: also, you're using the second index of the contact (which for particle-particle contacts, is a particle index) to access the collider handles array, which will result in an out of bounds exception. RE: Detect specific rope collision. - canerozdemir - 19-11-2020 (19-11-2020, 02:25 PM)josemendez Wrote: Well, you're writing the collider name to console once per contact, no wonder performance goes down the drain . Writing to the console is extremely slow. I wasn't paying attention to the documentation, I believe. I wasn't being careful, because I thought it would work like CollisionStay callback but I forgot that I am actually calling for a particle collision which is very expensive considering that I have over 4000 particles on the scene This code actually does what I want: Code: private void Solver_OnParticleCollision(object sender, ObiSolver.ObiCollisionEventArgs e) I can now receive an information about who collides with whom. Therefore, I can now detect when a rope is colliding with another one and I can use it to expand the gameplay further. Thank you for putting out the obvious that I was missing out . RE: Detect specific rope collision. - josemendez - 19-11-2020 (19-11-2020, 02:41 PM)canerozdemir Wrote: I wasn't paying attention to the documentation, I believe. I wasn't being careful, because I thought it would work like CollisionStay callback but I forgot that I am actually calling for a particle collision which is very expensive considering that I have over 4000 particles on the scene This code actually does what I want: That's 100% correct. Glad you got it working! . Forgive me for not giving you the solution straight away. I'm a bit hesitant of giving ready-made solutions for this kind of thing, as understanding the code you're using is paramount. Later down the road, fixing someone else's code that you didn't get to properly understand is often harder than writing your own RE: Detect specific rope collision. - canerozdemir - 19-11-2020 (19-11-2020, 02:50 PM)josemendez Wrote: That's 100% correct. Glad you got it working! . Ah yes, I can't argue with you there. However, you have been more than helpful to me in this couple of weeks. I never expected a fast support like this when I started using the Obi Rope. Thank you again for being a reliable provider RE: Detect specific rope collision. - Gauri7 - 04-07-2022 (19-11-2020, 02:24 PM)canerozdemir Wrote: Oh, I missed that one. However, the outcome is still the same. FPS drop happens and the game becomes unplayable. This is the code: why am I getting this error :- Assets/Scripts/RopeCollision.cs(37,58): error CS1061: 'Oni.Contact' does not contain a definition for 'particle' and no accessible extension method 'particle' accepting a first argument of type 'Oni.Contact' could be found (are you missing a using directive or an assembly reference?) Assets/Scripts/RopeCollision.cs(38,58): error CS1061: 'Oni.Contact' does not contain a definition for 'other' and no accessible extension method 'other' accepting a first argument of type 'Oni.Contact' could be found (are you missing a using directive or an assembly reference?) RE: Detect specific rope collision. - josemendez - 04-07-2022 (04-07-2022, 11:57 AM)Gauri7 Wrote: why am I getting this error :- Assets/Scripts/RopeCollision.cs(37,58): error CS1061: 'Oni.Contact' does not contain a definition for 'particle' and no accessible extension method 'particle' accepting a first argument of type 'Oni.Contact' could be found (are you missing a using directive or an assembly reference?) Hi, Contacts do not have “particle” or “other” member variables. You must use contact.bodyA to access the simplex, and contact.bodyB to access the collider. See the scripting section of the manual for details: http://obi.virtualmethodstudio.com/manual/6.3/scriptingcollisions.html RE: Detect specific rope collision. - Gauri7 - 04-07-2022 (04-07-2022, 01:23 PM)josemendez Wrote: Hi, yes I am using bodyA and bodyB but it always gives the wrong ropes ( I mean wrong names of colliding ropes ) this is the script : Code: using System.Collections; RE: Detect specific rope collision. - josemendez - 04-07-2022 (04-07-2022, 02:12 PM)Gauri7 Wrote: yes I am using bodyA and bodyB but it always gives the wrong ropes ( I mean wrong names of colliding ropes ) bodyA and bodyB are simplex indices, cannot be used to access the particleToActor array directly. You must get the particle index from the simplex index first. Check the sample code in the manual, the link I provided in the previous post. Cheers! RE: Detect specific rope collision. - Gauri7 - 05-07-2022 (04-07-2022, 07:52 PM)josemendez Wrote: bodyA and bodyB are simplex indices, cannot be used to access the particleToActor array directly. You must get the particle index from the simplex index first. Check the sample code in the manual, the link I provided in the previous post. hello , thanks , this thing worked i have one more question , can we have collision in only middle part of the rope ? ( no collision detection at end of the ropes only mid part) RE: Detect specific rope collision. - josemendez - 05-07-2022 (05-07-2022, 09:33 AM)Gauri7 Wrote: hello , You can control collision behavior for each individual particle in the rope. This is done using collision filters, see: http://obi.virtualmethodstudio.com/manual/6.3/collisions.html In-editor, filters are specified for each control point in the blueprint. At runtime you can set the filter value for each particle by writing into the solver.filters array. |