In my project, I am using a particlefx component to emit smoke particles during the acceleration of an object. The acceleration happens through an event triggered by the keyboard.
The problem is that as the user can keep the button pressed, the particle emitter is called in a loop making the particle buffer full
Causing the error: ERROR:GAMESYS: Particle FX component buffer is full (64), component disregarded.
Is there a way to check if the particle emitter is already activated to not activate it again or some better way to design this system?
Without knowing how the rest of how your code is working my suggestion would be:
You probably have right now on_input
if action_id == hash("some_key") then
accelerate(self)
end
and that function also calls the acceleration as well as the particle effect.
You could probably move the particle effect code to its own function instead, and change to something like:
if action_id == hash("some_key") then
accelerate(self)
if action.pressed then
--Function to make the particle effect)
elseif action.released then
--Function to stop particle effect, or same
--function but with a parameter start/stop
end
end
This should solve the problem at hand, but it might be better depending on what other actions you might have to create a state machine that handles all of this outside of the input pressed themselves.
edit tried twice to edit the 2nd code block on my terrible phone to format it properly and it wouldn’t stick. Sorry all…