Is there a way to change the extents of a Particles2D node's emission shape from script?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By artsyWraith7

I’d like to set the size of the particle effects based on the collision shape of the body that they surround at the time of instantiation.
I can’t seem to access anything about the node’s emission shape from script.

For example (albeit a crude one):

var p = particles.instance()
var size = entity.get_shape().extents
p.extents = size

:bust_in_silhouette: Reply From: kidscancode

The emission shape is a property of the ParticlesMaterial. If you hover your mouse on the material, you’ll see the property name is process_material. Hovering on the emission shape shows emission_shape. Since you said “extents”, I assume you’re using a “Box” shape, in which case the extents property is emission_box_extents.

So, to set it:

$Particles2D.process_material.emission_box_extents = Vector3(2, 2, 2)

All this and more in the ParticlesMaterial reference.

Works great thanks :stuck_out_tongue:

artsyWraith7 | 2020-05-20 20:13