Obi Official Forum
Help Setting ObiParticleAttachment ParticleGroup via script - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Help Setting ObiParticleAttachment ParticleGroup via script (/thread-1584.html)



Setting ObiParticleAttachment ParticleGroup via script - Bobsalot - 22-12-2019

Hi,

I'm an inexperienced developer and I'm not sure how I should be setting the ParticleGroup of a ObiParticleAttachment component via c# script.

I've checked the sample code and google, but it's still holding me up, anyone care to help out?  Huh

Thanks in  advance,
Bobs


RE: Setting ObiParticleAttachment ParticleGroup via script - Bobsalot - 09-01-2020

Anyone able to assist? this is still holding me back.

Thanks


RE: Setting ObiParticleAttachment ParticleGroup via script - josemendez - 11-01-2020

(09-01-2020, 03:17 PM)Bobsalot Wrote: Anyone able to assist? this is still holding me back.

Thanks

Hi Bob,

Particle groups are stored in the "groups" list of the blueprint. So simply do:

Code:
attachment.particleGroup = blueprint.groups[index];

(If you don't already have a reference to the actor's blueprint, you can get it like this):
Code:
var blueprint = attachment.actor.blueprint;

That's it.

You can see an example in ObiParticleAttachmentEditor.cs, which is the script for the particle group inspector.
There you'll see we use a GenericMenu to show a dropdown menu listing all the particle groups in the blueprint (by name). When the user picks one, the OnParticleGroupSelected() method is called (passing the group as a parameter). This method then assigns the particle group to the attachment's particleGroup property.


RE: Setting ObiParticleAttachment ParticleGroup via script - Bobsalot - 11-01-2020

(11-01-2020, 03:22 PM)josemendez Wrote: Hi Bob,

Particle groups are stored in the "groups" list of the blueprint. So simply do:

Code:
attachment.particleGroup = blueprint.groups[index];

(If you don't already have a reference to the actor's blueprint, you can get it like this):
Code:
var blueprint = attachment.actor.blueprint;

That's it.

You can see an example in ObiParticleAttachmentEditor.cs, which is the script for the particle group inspector.
There you'll see we use a GenericMenu to show a dropdown menu listing all the particle groups in the blueprint (by name). When the user picks one, the OnParticleGroupSelected() method is called (passing the group as a parameter). This method then assigns the particle group to the attachment's particleGroup property.

Thanks, Jose! Much appreciated Sonrisa


RE: Setting ObiParticleAttachment ParticleGroup via script - jalee - 23-01-2020

(11-01-2020, 03:22 PM)josemendez Wrote: Hi Bob,

Particle groups are stored in the "groups" list of the blueprint. So simply do:

Code:
attachment.particleGroup = blueprint.groups[index];

(If you don't already have a reference to the actor's blueprint, you can get it like this):
Code:
var blueprint = attachment.actor.blueprint;

That's it.

You can see an example in ObiParticleAttachmentEditor.cs, which is the script for the particle group inspector.
There you'll see we use a GenericMenu to show a dropdown menu listing all the particle groups in the blueprint (by name). When the user picks one, the OnParticleGroupSelected() method is called (passing the group as a parameter). This method then assigns the particle group to the attachment's particleGroup property.

Is there a way to access the particles within that group, so you can create particles groups and then do different things with them?


RE: Setting ObiParticleAttachment ParticleGroup via script - josemendez - 23-01-2020

(23-01-2020, 11:09 AM)jalee Wrote: Is there a way to access the particles within that group, so you can create particles groups and then do different things with them?

Yes, that's the point of particle groups.

A particle group contains a List<int> of particle indices in the actor:
Code:
group.particleIndices



RE: Setting ObiParticleAttachment ParticleGroup via script - jalee - 23-01-2020

(23-01-2020, 12:37 PM)josemendez Wrote: Yes, that's the point of particle groups.

A particle group contains a List<int> of particle indices in the actor:
Code:
group.particleIndices

Awesome, thanks Jose!