Multi-Resolution Game Development With GameBuilder Studio Check it out!
NEW Version 0.9.7 has arrived! New Blazing Fast Particle Engine & More Game Actions. Check it out
Particle effects change angle
  • Hi Lavon, hi all,

    I'm working on a cute little top down space game in which the player's ship is stationary on the center of the screen. He just change his angle and the objects on screen move around him depending in which angle he "accelerates".

    Now I would like to do a nice little engine exthause effect with particles. I use this site to create effects: - my problem is that these effects all have an emitter angle (they way the particles travel) which I don't seem able to manipulate in GBS. If my ship changes its angle, the "exthause" emitter angle should change in the same way, just in the opposite direction of the ships facing. How can that be done? I only found values for "emitAngleAlignedToRotation" but this seems to do nothing (or I manipulate it in the wrong way).

    Also I wonder about the best way to "stick" the particle effects to a certain place of the ship. I understand that this could be done very easy with spine (but not sure if I want to buy it just for that). My second idea was to drastically reduce the livespan of the particles and calculate their position every tick with a fitting offset to the center of the ships image (like Lavon did it with the gunshots in the turret demo). Or does anyone know a better way for that?
  • 7 Comments sorted by
  • Hi @Cavaron 

    Yes the emitAngle should have been exposed but it wasn't Here is a little known trick when using GBs. All components are really just Classes under the hood so they have properties that may or may not be exposed via the GBs editor. So there is a property on the Particle Renderer called "particleEngine" which you can access the emitAngle value directly to change the angle of the emitter until we expose the "emitAngle" property in the next build.

    To position the emitter to a spot on the ship just use a Constrain Property action to set the x/y position of the particle renderer to the position of the ship plus an offset value in both x and y.
  • Hi Lavon,
    thanks for the hint with the emitAngle! To constrain the position of the particle renderer sems to be a tougher nut. It refuses to rotate with it's spacial. I put a particle renderer and a shape renderer together (controlled by the same spacial). I also did set the particle rendere from rotation: -1 to 0, like the other one. The shape rotates perfectly, the particle renderer wont:

    Any ideas how I can stick it to the engine exhaust? (The ship is centered in the middle of the screen, it only rotates in the direction it is "flying").
  • @Cavaron the secondary renderer on the same entity, I believe, is only tied to the shared Spatials' position. In GBs when you have two renderers on the same entity one has to be the dominate or rather the main "controlled" renderer for the main Spatial on the entity. Any other Renderers added to the entity after the first one are not completely controlled by the main Spatial so that the second renderer doesn't take on the exact same position, size, and rotation of the main "controlled" renderer. This is the default behavior in GBs but it can be changed at runtime.
    So if you want to bind the rotation of the Particle renderer (which in your case is the secondary renderer) to the shared Spatials' rotation value you have two options. You can use a Constrain Property action which will constantly copy over the rotation value from the Spatial.rotation property to the ParticleRenderer.rotation or you can pass an actual property reference object to the "rotationProperty" property on the ParticleRenderer which points to the Spatial.rotation property which will cause the renderer to internally grab the rotation property for you. The "rotationProperty" is a property reference built into all renderers. The way that you pass the property reference is by using a Change Property action at runtime and selecting Property Reference as the value type. Then uncheck the "pass reference value" check box. It will actually pass the Property Reference object instead of grabbing the value of the property at that referenced address.
  • @Cavaron also keep in mind there are two levels of rotations when it comes to Particle Renderers in GBs. You can rotate the entire Particle simulation/system by changing the rotation value of the Particle Renderer itself or you can rotate just the emitter of the Particle system using the emitAngle property which will just change the direction/angle that the particle system initially spawns particles in.
  • @Cavaron the "emitAngle" property is now exposed in the latest build 768/769. Along with "startRotation", "startRotationVariance", "startSize", and "startSizeVariance" which are all Number/Float values.
  • @Lavon Sorry, I couldn't get it to work. I did some tests and I think there is something wrong. Have a look at this project:
    The spatial is submitting its rotation to every nested renderer without any specified constraining or referencing. The position of the yellow shape is realised with offset position values, the position of the purple one with registration point values. The purple one rotates correctly holding its relative position to the plane sprite. The yellow one rotates more or less around its own center. The particles renderer does nothing I could spot.

    So if I want to stick a particles effect to the back of the plane, capable of rotating with it, there are two problems:
    - The particles renderer doesn't seem to have a changeable registration point.
    - If it had one, I'm not sure it would do anything, because it does not even behave like the yellow shape (I tested several offset values without visible results).

    Any ideas on that? Because an effect like that would be really cool for my space game ;)
  • @Cavaron a new build with a fix for this issue is on the way. It will just be as simple as checking the "Align Emitter Angle To Rotation" checkbox.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion