Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Cloth scripted particle attachment in runtime
#1
Hi,




I am trying to simulate cloth manipulation in Unity 2019.6.16 and Obi Cloth 5.




Currently, I am attaching a sphere to a particle group on the cloth and have written a script allowing me to control the sphere with my mouse (images below).




I want to be able to grasp (click) anywhere on the cloth and manipulate it, and I know there is a better way than creating a few hundred spheres and attaching them individually to each particle in the cloth.




My issue is that I am fairly new to Unity and Obi Cloth, and I am totally stuck on how to script this type of interaction. Specifically, I am not quite sure where to start, should I be modifying the "ObiParticleAttachment.cs" associated with the cloth, or should I create a new .cs file? If I create a new .cs file then how do I access/reference my cloth and its "Obi Particle Attachment" component?




Thanks,


Ben
Reply
#2
Hi Ben,

There's a sample component that let you click on any actor and drag it around: ObiParticleDragger.

When you add a ObiParticleDragger, a ObiParticlePicker will also be added as a dependency. The picker raycasts against all particles and raises events for particle click/drag/release. The dragger subscribes to these events and applies spring forces to move the picked particle(s) around.
Reply
#3
(17-12-2020, 09:01 AM)josemendez Wrote: Hi Ben,

There's a sample component that let you click on any actor and drag it around: ObiParticleDragger.

When you add a ObiParticleDragger, a ObiParticlePicker will also be added as a dependency. The picker raycasts against all particles and raises events for particle click/drag/release. The dragger subscribes to these events and applies spring forces to move the picked particle(s) around.

Hi Jose,

Thanks for the suggestion and the very quick reply, that component is exactly what I was looking for!

Thanks, Ben
Reply