Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Collider Effect On Obi Cloth Stops After A Few Seconds.
#4
Your PressureObjectManager looks ok, although there are a few things that aren't immediately obvious to me. They might not be related to the issue at hand, though:

- Why do you perform a raycast against all colliders in the scene when pressing down? What do you need to raycast against? Wouldn't a simple cast against a plane be enough? (or even no raycast at all, if using a full-screen orthographic view)

Code:
objPosition.y = -1;  //Account For Pressure

- You're lowering the collider one meter in the y axis to account for pressure, when creating the object as well as when the user drags around. So I assume you have some sort of collider above the cloth mesh, that you use to detect touches against using a raycast, and then create a "pressure object" collider one meter below this raycast object, where the cloth is?


Regarding the particle picker, it is a "courtesy" script that keeps track of a single particle and raises picked, held, dragged and released events passing the particle index and position to anyone subscribed to these events. The dragger subscribes to the picker events at runtime, and deals with the physics of the picked particle. This is what the dragger's OnEnable method looks like:

Code:
picker = GetComponent<ObiParticlePicker>();
picker.OnParticlePicked.AddListener(Picker_OnParticleDragged);
picker.OnParticleDragged.AddListener(Picker_OnParticleDragged);
picker.OnParticleReleased.AddListener(Picker_OnParticleReleased);

You can of course subscribe your own scripts to these events in-editor, they're UnityEvents.

The picker is intended to offer basic scaffolding to build more complex systems on top, but it does not take advantage of multitouch. You're expected to use the particle API to move particles around in response to input, just like you'd use Unity's rigid body API to make rigid bodies react to input. After all, Obi is a physics engine, not an input system.

If you take a look at the picker's code you'll see that it reacts on Input.GetMouseButtonDown(0): iterates over all particles calculating their distance to a ray cast from the mouse position, and stores the index of the closest one. Adding multitouch capabilities on top of that involves casting one ray per finger instead of only one, and keeping track of one particle per finger, so it's only a bit more complex.

Quote:I'd also like to be able to control what happens when I click and drag and the only way there seems to be to modify the behavior is through the constraints and parameters on the solver and the dragger component but I can't really produce the results I'm looking for with just that so I'm thinking I need to actually interact with the particles themselves.

Then you'd have to write your own "dragger". The built-in one calculates a spring force and applies it to the particle, it's efficient and reasonably customizable via the spring parameters. But there's tons of other ways to interact with a particle/object: teleport it to a new position? change its velocity directly? apply an impulse? we cannot possibly cover them all.

Quote:Is it possible to select multiple particles at a time like the blueprint editor aside from trying to determine what indices the particles around them would be at? If so, could you provide a link to maybe some sample code on the basics of it like unity has for the raycast or write me a quick snippet?

Just like you don't have built-in object selection in Unity, and you must store a reference to them somewhere, "selecting" a particle is not something built-in in Obi. To select a particle you simply keep track of its index somewhere (in a variable, in an array, etc). Keep in mind that a particle is just an index, just like entities in Unity's ECS system.

The usual approach is to simply iterate through all particles, find the ones you're interested in, and store their index. The manual has several sample scripts that filter out specific particles based on some criteria, and then does something with them. The last sample found in this link fixes all particles within a given distance to a transform:

http://obi.virtualmethodstudio.com/tutor...icles.html
Reply


Messages In This Thread
RE: Collider Effect On Obi Cloth Stops After A Few Seconds. - by josemendez - 03-02-2020, 08:26 PM