Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Way to Attach Game Object?
#1
Is there a simple way to manually attach a game object to a softbody? I just want an object to follow a point or particle on the softbody without influencing the softbody at all, as if the game object were just along for the ride.

I tried the attachment component with both static and dynamic options. Neither give me good results since static will not allow the object to be influenced by the softbody and dynamic causes some wonky and unpredictable 2 way interaction. I noticed some threads here where colliding objects can attach to a softbody at runtime, but I want to set this up manually in edit mode so the game object is always on a specific part of the softbody from the get go. I also tried the obi contact grabber, but that doesn't seem to do anything.

I am not a programmer so I have no idea how to script something like this myself. Any help would be much appreciated!
Reply
#2
(20-11-2021, 09:13 PM)beegon Wrote: Is there a simple way to manually attach a game object to a softbody? I just want an object to follow a point or particle on the softbody without influencing the softbody at all, as if the game object were just along for the ride.

I tried the attachment component with both static and dynamic options. Neither give me good results since static will not allow the object to be influenced by the softbody and dynamic causes some wonky and unpredictable 2 way interaction. I noticed some threads here where colliding objects can attach to a softbody at runtime, but I want to set this up manually in edit mode so the game object is always on a specific part of the softbody from the get go. I also tried the obi contact grabber, but that doesn't seem to do anything.

I am not a programmer so I have no idea how to script something like this myself. Any help would be much appreciated!

Hi!

Attachments are designed to attach softbodies to other objects, if using a dynamic attachment doesnt do what you need (it should, as it enables two way coupling with rigidbodies) you have two other options: a) use a ObiSoftbodySkinner to bind the object to the softbody (it will deform along with it ) or b) write some code in case you want the object to keep its original shape. All you need to do is pick the closest softbody particle, then copy its position/orientation to the object. This is done using the particles API, see:

http://obi.virtualmethodstudio.com/manua...icles.html

Should be fairly easy, but if you’ve never written code before it may be a challenge. Obi is not really targeted at beginners, it’s an advanced physics engine and advertised as such. To be able to use Obi you need to have basic/intermediate coding skills, as explained in our FAQ:

http://obi.virtualmethodstudio.com/faq.html

On Monday I will write some sample code for you if you need.

Kind regards,
Reply
#3
(20-11-2021, 10:08 PM)josemendez Wrote: All you need to do is pick the closest softbody particle, then copy its position/orientation to the object. This is done using the particles API, see:

That makes sense and sounds like exactly what I need. I only know basic programming, but I will try to understand how to do this in the meantime. Thank you for the pointers!
Reply
#4
(21-11-2021, 01:47 AM)beegon Wrote: That makes sense and sounds like exactly what I need. I only know basic programming, but I will try to understand how to do this in the meantime. Thank you for the pointers!

Hi there,

Sorry for the delay, it's already tuesday. You can find the sample script attached. To use it, add the component to the object you want to attach, then drag the softbody to its "softbody" input.

What it does is it finds the particle that's closest to the object, and stores the object position/rotation in the particle's local space. At the end of every frame it just translates/rotates the object to match the stored position/rotation. A possible improvement would be to consider more than just the closest particle, but the "n" closer ones. This would essentially boil down to linear blend skinning (which is what the built-in ObiSoftbodySkinner component does on a per-vertex basis).

Note the object just goes along, has no interaction with the softbody at all. Here's a video:



Let me know how it goes Sonrisa


Attached Files
.cs   AttachToSoftbody.cs (Size: 2.79 KB / Downloads: 23)
Reply
#5
Corazón 
Wow, thank you so much! This is exactly what I needed and it works great. No worries on the delay, I'm just grateful for the help. I tried to dig through the existing code to create something like this, but I couldn't get it to work. Your comments in this script help me understand it a lot better. I really appreciate you taking the time to do this!
Reply