Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble with Attachments
#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


Messages In This Thread
Trouble with Attachments - by beegon - 06-02-2025, 11:31 PM
RE: Trouble with Attachments - by josemendez - 07-02-2025, 09:32 AM
RE: Trouble with Attachments - by josemendez - 07-02-2025, 09:48 AM
RE: Trouble with Attachments - by beegon - 07-02-2025, 08:29 PM