![]() |
Can I translate all the particles' position by a certain vector? - 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: Can I translate all the particles' position by a certain vector? (/thread-2475.html) |
Can I translate all the particles' position by a certain vector? - emz06 - 07-09-2020 Hi, -I have fluid particles (shampoo-type of liquid) resting on a platform. -Suddenly this platform shifts downward, and to the side. But the problem is the particles can't keep up with the high speed of the platform. I tried to increase the friction, but it did not help. Is it possible to loop through all the particles and, on every frame, translate their position by the same amount as the platform movement? RE: Can I translate all the particles' position by a certain vector? - josemendez - 07-09-2020 (07-09-2020, 11:36 AM)emz06 Wrote: Hi, Yes, you can. Make sure to also translate their previousPosition, as this is PBD (and velocities are calculated as (position - prevPosition) / dt). If you only change their current position, they will gain a lot of velocity. See: http://obi.virtualmethodstudio.com/tutorials/scriptingparticles.html Example: Code: for (int i = 0; i < actor.solverIndices.Length; ++i){ RE: Can I translate all the particles' position by a certain vector? - emz06 - 11-09-2020 Hi, Thanks for that. I tried to make a coroutine for that, but I don't understand some of the structures involved, as well as the presence of a Vector4 as the translation. Please see my code below. Note: the platform is moved by IK, so the movement happens at the end of the frame. What did I do wrong there? Code: public IEnumerator ParticlesFollowPlatform_IE() |