Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Is there any way to fix cloth on specific point?
#8
(06-09-2024, 09:30 AM)gahyun11 Wrote:
Code:
obiSkinnedCloth.GetComponent<ObiParticleAttachment>().particleGroup = communicate._obiSolver.actors[0].blueprint.groups[0];

All cloth assets blueprints that we have have no particle groups, same as body asset blueprints.

Hi,

If your blueprints have no particle groups, how can you expect the above code to work? this code assigns the first particle group to the attachment, if there's no groups in the blueprint this will throw an index out of bounds exception. You can't attach a cloth with no particle groups: it stands to reason that you must have at least one group of particles to attach. Maybe I'm misunderstanding your goal?

Furthermore your code assigns a particle group belonging to an actor that may not be the one being attached, which of course won't work: there's no guarantee the first registered actor in your solver is the same cloth whose attachment you're modifying. Correct code would be:

Code:
obiSkinnedCloth.GetComponent<ObiParticleAttachment>().particleGroup = obiSkinnedCloth.blueprint.groups[0];

or, depending on your particular use case:

Code:
communicate._obiSolver.actors[0].GetComponent<ObiParticleAttachment>().particleGroup = communicate._obiSolver.actors[0].blueprint.groups[0];

(06-09-2024, 09:30 AM)gahyun11 Wrote: I just tried this one and it didnt work well again. Please let me know if I miss something. The '_obiSolver' gameobject is the body gameobject .

Code:
obiSkinnedCloth.GetComponent<ObiParticleAttachment>().particleGroup = communicate._obiSolver.GetComponent<ObiActor>().blueprint.groups[0];

This code doesn't make any sense: you're attempting to retrieve an actor component from the solver gameobject, which will throw a null reference exception since the solver does not have such a component. Make sure you understand GameObjects and Components clearly, it's pretty important to familiarize yourself with the basics first.

kind regards,
Reply


Messages In This Thread
RE: Is there any way to fix cloth on specific point? - by josemendez - 06-09-2024, 10:32 AM