Skip to content

Particles - get/set #151

@paweljarosz

Description

@paweljarosz

Describe the example you'd like
1.12.2 adds get/set support for first emitter properties - we should showcase how to use them in a simple example

Additional context (optional)
Here you can specify references (screenshots, links) of what you would like to see in the example.

NEW: (#3417) ‘Get and set properties from ParticleFX emitters’ by Jhonnyg
The first iteration of getting and setting properties for particlefx emitters via go.get / go.set is now available:

go.property("my_material", resource.material())
function init(self)
local cone_material = go.get("#particlefx", "material", { keys = {{ emitter_id = "cone_emitter" }}})
-- change the material for the next time the particlefx is played
go.set("#particlefx", "material", self.my_material, { keys = {{ emitter_id = "cone_emitter" }}})
end
Important note: The changes invoked via go.set will NOT affect the currently playing particlefx, they will only have an effect when playing the fx next time. For example, if you want to change material in an input handler, you need to first stop the particlefx and then play it again:

function on_input(self, action_id, action)
if action_id == hash("space") and action.released then
particlefx.stop("#particlefx")
go.set("#particlefx", "material", self.my_material, {keys = {{ emitter_id = "cone_emitter" }}})
particlefx.play("#particlefx")
end
end
The properties we currently support for emitters are:

“material” - get and set the emitter material
“image” - get and set the emitter image, i.e atlas or tile source used for rendering
“animation” - get and set the animation (the animation must exist in the image!)
As this is the first iteration of this feature, very few properties are available. In the future, we hope to support more properties and even curved properties!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions