I am wondering how to work a particle emitter into the whole entity thought. Using TestExplosion from the JmeTests, how can I incorporate the timing of particleemitter effects into the scene. Should control of the particle models/nodes/spatials be done in a SpatialState? Any good ideas ? Looking for any any all hints
The particle emitter is not really a game object itâs the visual effect of some game objectâs current state. So in the visualization layer youâd have something watching for that game data and then trigger the visual effect.
Without more specifics itâs really hard to give better examples.
I know from your example games, youâve created a SpatialState to add/remove/update spatials to/from/in the scene. Would it make sense to create an EffectState, that listens for Entities with a specific component âEffectâ and âTypeâ, and then displays them accordingly? Iâm also wondering how to link the example âDecayâ component to the effect timing.
Say I need to display the TestExplosion effect in the scene. I know when to add an entity âEffectâ. Per âeffectâ component, I would need to keep track of the timing of that specific ParticleEmitter-node (to make sure the explosion effect is carried out - using emitAllParticles and killAllParticles. Does that make sense?
If the effect has a certain duration then thatâs part of the visualization. A Decay component doesnât come into it really since thatâs part of the game objects.
I mean I guess it depends on if you really DO want removing the effect game object to also remove the visual object even if itâs not done yet. Else Iâd treat the effect visualization as a fire-and-forget style thing when you see the effect game object. Just have the emitter clean itself up when itâs done.
I think I can rephrase my questions a bit to be more specific:
Would you ever have something happen after the decay ? (say, a bullet that needs to be removed, but it explodes when before its removed - how would you handle this)
You essentially decouple the game objects and the visualization (entities and the effects) ? So if I want something to happen graphically after a game object is removed, the graphic/effect is firing even while the game object is no longer there
How do you handle events in your games ? Say I want some entity to last for a while (I can use the decay here) but when its decayed I want some new entity to enter. Iâm thinking of creating a component 'transform(delay in ms, component ⌠list), so that when the system listening for transforms acts on the delay (much like the decay state removes the entities after the delay), it removes the entity and creates a new entity with the list of components. But that creates a structure of components within components (components lying dormant until they are âactivatedâ). I may have asked about eventing before, and iâll go look on the forums for it
What if there was a world with no hypothetical questions?
Iâm having trouble answering wildcard questions so you may have to come up with a concrete examples. So far the only one I can even remotely comment on is the bullet example:
Why did it explode? Why is it being removed?
Once the game object has decayed, itâs gone. That doesnât mean there couldnât be a bunch of visual effects still lingering.
So many of these questions seem to be still confusing game objects with visualization.
Pretend you have a network app with a client and server. What does the server have to know? Those are your game objects. Does the server need to know that the bullet explosion produced a flash of light and a bunch of little fragments? Nope, probably not.