Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Suggestion / Idea  Manipulating Particles Individually
#1
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. Gran sonrisa
Reply
#2
(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
OR
Is there a way to just use a collider as a trigger for all these particles without causing the game to lag?

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/tutor...icles.html
http://obi.virtualmethodstudio.com/tutor...sions.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. Gran sonrisa

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. Sonrisa
Reply
#3
(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.

The manual contains a scripting section that explains both:
http://obi.virtualmethodstudio.com/tutor...icles.html
http://obi.virtualmethodstudio.com/tutor...sions.html


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.


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. Sonrisa
Reply