Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble with Attachments
#1
I'm trying to attach some objects to a softbody via Obi Particle Attachments. 

I created some particle groups in the blueprint and assigned the objects to their respective particle group in the attachments. I want the objects to maintain their orientations relative to their particle group and I don't want the attached objects to influence the softbody if possible. I've tried every option and configuration I can think of, but the behavior is always undesirable or unstable.

   
I want the spikes to stick out of the ball like this and maintain their relative positions and rotations as the ball rolls around.


.gif   SoftbodyAttachments.gif (Size: 787.22 KB / Downloads: 8)
Instead the objects drift away from the surface or roll around their local axis. They also seem to pull the softbody around a bit instead of just going along for the ride, which is undesirable.

Is there a way to achieve the behavior I'm looking for? Or maybe I'm missing something with my setup? Any thoughts are appreciated. I can link you this project if you'd like to see my setup. Thanks!
Reply
#2
Hi,

You can't use particle attachments to do this: as the name implies, static attachments statically attach the particle to the object (not the other way around) and dynamic attachments use forces so that the the objects is affected by particle motion and vice-versa.


What you want is to copy the particle position/orientation to the object, simple as that Sonrisa. You can do this using the particles API. Example:

Code:
using UnityEngine;
using Obi;

public class GlueToParticle : MonoBehaviour
{

    public ObiSoftbody softbody;
    public int particle;

    void LateUpdate()
    {
        if (particle >= 0 && particle < softbody.activeParticleCount)
        {
            int solverIndex = softbody.solverIndices[particle];
            transform.position = softbody.solver.renderablePositions[solverIndex];
            transform.rotation = softbody.solver.renderableOrientations[solverIndex];
        }
    }
}

You could add a number of improvements to this script, such as adding a position/orientation offset, or find the closest particle and automatically glue the object to it, or get the particle index from a particle group, etc.

kind regards
Reply
#3
Follow up: your question sounded familiar, so I searched the forum and found that you asked the exact same thing 4 years ago:
https://obi.virtualmethodstudio.com/foru...ght=attach

In that thread I wrote a more elaborate version of the script in my previous answer, which finds the closest particle in the softbody and automatically calculates position/rotation offsets for it.

Since you've asked again, I take it that this solution didn't work for you for some reason? Do you need any help getting it to work for your particular use case?

kind regards
Reply
#4
The method you provided in that old post was useful, but it had a few edge case issues. I adjust the scale of the obi solver to grow or shrink the softbody, which caused the attachments to float away from their attachment points.

I tried doing something similar to your suggestion here and it works perfectly. I still use particle groups, but I get the average position and orientation of all the particles in the group and tell the game object to follow that average, plus some offset values to get it in just the right spot.

It works great and holds up even when the solver is scaled. Thanks for your help and pointing me in the right direction!
Reply