05-09-2019, 11:26 AM
(This post was last modified: 05-09-2019, 11:29 AM by josemendez.)
(04-09-2019, 05:48 PM)neecko Wrote: Hey there.
I have been playing around with the particle grabber and haven't had any luck trying to do the following:
1. Grab a group of particles instead of just 1. Ideally it would grab the closest one clicked and then a few surrounding particles. I tried a few different things, but had no luck.
2. On release the particles snap up sharply. I tried playing with the inverse mass, but haven't had a lot of luck there either. What I would like to happen is for the particles to gently fall in place when the particle is released.
Thank you
Hi there,
I assume you're using the ObiParticlePicker class.
1. Should be pretty straightforward. Once you click and the pick the closest particle to the camera ray, simply add a loop to iterate trough all particles and store the indices of those that are within a certain radius of the picked one. You will then need to modify ParticlePickEventArgs to pass in a list of particles instead of a single one. (For instance, use List<int> instead of int for the indices, same for worldPositions)
2. Mass does not determine how fast particles move, it just doesn't work that way (not in real life, either). You need to apply an external force, or alternatively use damping to make particles lose kinetic energy. Depending on the exact result you're after this can be achieved in multiple ways, however they all involve modifying particle velocities (either directly or trough forces).