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
I’m guessing you mean like in an entity system?
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.
Maybe its a kind of eventing I’m looking for…
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
Appreciate your feedback!
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.