Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Can I attach particeattachment in script?
#1
Hello! I'm currently trying to add particle attachment component through the script before obi skinnedcloth asset is enabled during play.
The issue that I'm struggling is if I add particle attachment into cloth asset during the play using my script(below), particle attachment doesnt work, just falls until it reaches at pelvis, 
but! if I add particle attachment into same cloth asset before play, particle attachment works well!

both of the cases particle attachment is added into cloth asset well, but the problem is particle attachment doesnt work only if I add it on the cloth asset(object that has obi skinnedcloth component) through the script

<add particle attachment component through inspector before play>
   

<add particle attachment during the play through script>
   

and this is the script I wrote. I tried same part on "OnEnable","Start","Awake" and all of this didnt work.
I tried to add particle attachment component on disabled cloth, then I enable cloth asset, it didnt work. 
Particle attachment worked only I added that component on cloth asset through inspector whether it was play runtime or not. 
 
Code:
  obiSkinnedCloth.gameObject.AddComponent<ObiParticleAttachment>();
            obiSkinnedCloth.GetComponent<ObiParticleAttachment>().target = _clothEnabler._obiSolver.transform.GetChild(1);
//this is the part that I set body as particle attachment's target, and the body has mesh collider and obi collider.
            try
            {
                obiSkinnedCloth.GetComponent<ObiParticleAttachment>().attachmentType = ObiParticleAttachment.AttachmentType.Dynamic;
                obiSkinnedCloth.GetComponent<ObiParticleAttachment>().compliance = _clothEnabler._particleCompliance;

            }


is particle attachment something that I cannot add in script during play runtime? Thank you.
Reply


Messages In This Thread
Can I attach particeattachment in script? - by gahyun11 - 12-09-2024, 06:18 AM