Suggestion / Idea Manipulating Particles Individually - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Fluid (https://obi.virtualmethodstudio.com/forum/forum-3.html) +--- Thread: Suggestion / Idea Manipulating Particles Individually (/thread-2844.html) |
Manipulating Particles Individually - ProudRoach - 05-04-2021 I have read somewhere that these particles are indexed. I have had a hard time this last year in finding how to use this to my advantage. How would you grab each particle and then apply forces or velocities to them individually OR Is there a way to just use a collider as a trigger for all these particles without causing the game to lag? I would like them to change direction based on the angle they enter an area and have each area apply different forces or velocities to the particles. The difficulty for me is that I need them to have a velocity while they are in this area instead of applying it once they enter and seeing those changes afterwards. RE: Manipulating Particles Individually - josemendez - 06-04-2021 (05-04-2021, 11:28 PM)ProudRoach Wrote: I have read somewhere that these particles are indexed. I have had a hard time this last year in finding how to use this to my advantage. How would you grab each particle and then apply forces or velocities to them individually Manipulating individual particles/contacts at runtime is an integral part of Obi. The former is done using the particle API, the latter done using collision callbacks. The manual contains a scripting section that explains both: http://obi.virtualmethodstudio.com/tutorials/scriptingparticles.html http://obi.virtualmethodstudio.com/tutorials/scriptingcollisions.html (05-04-2021, 11:28 PM)ProudRoach Wrote: without causing the game to lag? This part completely depends on how you implement your custom logic. Obi exposes flat arrays of contiguous, blittable particle data, so cache utilization is optimal and multithreading straightforward. This is the same data accessed dozens of times per frame by the engine itself. There's no reason for it to be slow, if implemented properly. All examples in the documentation are single-threaded for the sake of simplicity. (05-04-2021, 11:28 PM)ProudRoach Wrote: I would like them to change direction based on the angle they enter an area and have each area apply different forces or velocities to the particles. The difficulty for me is that I need them to have a velocity while they are in this area instead of applying it once they enter and seeing those changes afterwards. While particles are in contact with a trigger collider, Obi will report contacts between them every frame. You just need to identify which contacts involve the trigger, then set the velocity of the corresponding particle. Let me know if you need help with this. cheers! Edit: I just added some sample code to the collision callbacks page, showing how to change particle velocities while they're inside a trigger. RE: Manipulating Particles Individually - ProudRoach - 08-08-2021 (06-04-2021, 07:07 AM)josemendez Wrote: Manipulating individual particles/contacts at runtime is an integral part of Obi. The former is done using the particle API, the latter done using collision callbacks. |