07-02-2025, 09:32 AM
(This post was last modified: 07-02-2025, 09:34 AM by josemendez.)
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
. You can do this using the particles API. Example:
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
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

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