07-05-2021, 01:31 PM
(This post was last modified: 07-05-2021, 01:36 PM by Spectra_7.
Edit Reason: Few changes to clear misunderstanding
)
Okay I tried what you said.
It did kinda worked what I wanted, but some of the spheres are inside the softbody whereas some are outside floating in air.
HandleGlitters() is called in update method.
Sorry I am still noob in coding. Am I doing something wrong here?
I have attached a screenshot.
It did kinda worked what I wanted, but some of the spheres are inside the softbody whereas some are outside floating in air.
Code:
Component contactObject;
if (ObiCollider.idToCollider.TryGetValue(e.contacts.Data[i].other, out contactObject))
{
if (contactObject != null)
{
if (contactObject.gameObject.CompareTag("Glitter"))
{
Glitter glitterInstance = contactObject.gameObject.GetComponent<Glitter>();
if(glitterInstance != null)
{
if(!glitterInstance.isAttached)
{
glitterInstance.isAttached = true;
glitterInstance.glitterRigidbody.isKinematic = true;
glitterInstance.glitterObiCollider.Phase = 1;
glitterInstance.particleIndex = e.contacts.Data[i].particle;
glitterInstance.particleAttachOffset = slimeActor.GetParticlePosition(glitterInstance.particleIndex) - (Vector3)e.contacts.Data[i].point;
if (!glittersList.Contains(glitterInstance))
glittersList.Add(glitterInstance);
}
}
}
}
}
private void HandleGlitters()
{
if (glittersList.Count <= 0)
return;
for (int i = 0; i < glittersList.Count; i++)
{
var particlePos = slimeActor.GetParticlePosition(glittersList[i].particleIndex);
glittersList[i].transform.position = particlePos - glittersList[i].particleAttachOffset;
//glittersList[i].SetPosition(Pos);
}
}
HandleGlitters() is called in update method.
Sorry I am still noob in coding. Am I doing something wrong here?
I have attached a screenshot.