Better Stack Beams?

Hello,

I was wondering how I could make a more easy system to stack a beam ( getting an upgrade provide you a better beam)

I made it with all the variations (which is really long and a pain to change if I need to make even a minor change.

I have more than 30 group events for all my variations…

and in each groups, there is thoses events that change what the beam and the flare look like

But I guess there is an easier way to do so… anyone can help me reduce those 30 events group ?

This got lengthy but I think you could shrink it to just 1 event using variables, create object by name and other methods. I’m on my phone. So, I can’t really make a mockup. I also don’t know which parts are unique to each weapon.

These changes may be difficult to apply now depending on how far along with the project you are. You may be able to implement all or just some of them. Every bit helps.

What if instead of a different variable for each beam you use a single variable for beam type or weapon type and you change just that variable. You would then need to only check that one variable.

If weaponType variable contains "beam"
Check the various keys

Put the beams into a group, if the flares are different then create a group for them as well. 

Actions
Create object by name weaponType from beam group

Create object by name weaponType +"_flare" weaponType from beam flare group
(if the flare style changes) 

Any action or condition based on the beam or flare would use the beam or flare group name. As long as it's the same event it sube sent it would use just the picked group objects. 

Sub event
If animation equals the list of animation name
or maybe if animation contains "Left" 
Then flip the object

You may need to do the same for applying force if it changes based on flip status. One for flip, one for not flipped. 

If other things like force or position or even kepress changed depending on the weapon type then you could create a structure of structures with a structure of each beam with a structure of things like force or any other unique property.

Weapons.smallBeam.Force = 300

Apply force Weapons[WeaponType].Force

If the direction of the applied force chamgea based on the flip status, you may need separate subevents to apply force based on flipped status then apply the force via the structure value. For the one state you could apply force variable *-1

If they use different sound unfortunately there’s not a play sound by name. There is an extension to play by filename or you could list the different sound conditions as sub-events. At least it would still just be once.

Alternatively, you could create an extension to play the sounds by name. You pass it the weapon and it could use a bunch of events with conditions if this play this, if that play that. That would clean up the main event sheet and with the sounds in 1 place you could make tweaks on 1 place.

You can reduce repetition with group objects

1 Like

I tried to do you code before, cause I already though about global groups, but it doesn’t seem to work… I’d really like an example…

Sure. Here’s a simplified platformer. I think I captured my concept.

try me:
https://gd.games/keith_13579/multi-beams

project: (Click the green [code] and [download zip]
https://github.com/doug13579/Gdevelop-shoot-with-object-group
.


.


.

Ok, I get the structure, but my beams are differents and individuals sprites for exemple I have “pw_beam” and then “large_beam” So how the game will know I change from the pw_beam to the large_beam ?
Is it with the variable for exemple pw_beam is assigned to “beamA”, large_beam to “BeamB” etc… ?

Can you screenshot a couple of the other beam event groups? Maybe, instead of adding the objects individually, you could use external layouts and add it by name.

I have only one group where everything is in

Should I split it up all ?

OK. I understand. I thought you meant that each beam was made of multiple objects. My mistake.

Yes, your array could use the names of the beams and you would pick the the child structure based on that name. Everything could match.

Replace BeamA with the object name and then set the variable that tracks the current beam to that name to access the speed if needed and then use the same variable to add the object(s) by name and decide which sound to play, again if that’s needed.

Edit: oh, and when I asked about the other groups, I meant event groups. I just want to compare how a couple of the different beams were added. Although, seeing the object group also helps.

It can be difficult to make suggestions based on tiny snippets. Although, the oppose is also true because too much info causes people’s eyes to glaze over.

But it is actually my structure each beam have it’s own variabla but I need to split it up because there is a synergie between beams…

IDKW you mean by that. If you need the separate variables then there’s no reason that you can’t use both systems either together or different parts. You can modify things to fit your needs

Your situation is a bit more difficult because it’s already written. It might take a lot of reworking. It would streamline things but it might not be easy.

For exemple, I start with the pw_beam, then I collect plasma_beam so I get regular one, but if i also collect large_beam it become a plasma_beamlarge

Do the multiple beam types fire at the same time or does the player get the ability to fire a more complex beam based on unlocking the other beam types?

No, it’s like in metroid if you have the time to check it out,
You start with a base beam, and it upgrade when you pick up the beam’s object.
So when you get from pw_beam to plasma, you only fire plasma

I’m vaguely familiar with the game. My method is based on an activeBeam variable. If the variable is one beam it adds that beam. How you set the activeBeam is up to you. Whether it’s fixed or changeable by the user is up to you. Are you using the mixing of the different modules to create multiple different weapons?

I do use the mixing of differents one to creates individual beams, for exemple picking some upgrades without others makes a whole other beam, but leads in a way or another to the same results at the end

( for exemple picking ice_beam lead to pw_icebeam and the picking plasma leads to plasma_ice / Or you can pick plasma so it leads you to plasma_beam and then the icebeam and it will lead to the same result : plasma_ice)

I don’t know how to handle the mixing and matching. You might be able to build the name based on the values of the selected modules but IDK enough about Metroid.

That’s why I made that LONG code about the mixing but I think there is a way to tell that when 2 differents type are picked then it is " x beam" etc…

This would build the name. IDK if all of combinations are valid.

Again, I don’t understand the system.

That’s a bit hard to explain… but the beams combine one to each other…
Without speaking of beams, let’s speak of ingredients :
You start with a tomato in hands, and then you find a pasta, so you end up with pizza, later you find some shrooms, so you end up with a shroom pizza etc…
Hope this make it clearer haha

I understand the basic principle. This would combine them in a consistent way.

You would always have “FireIce” and not “IceFire” because of the way it’s added to an empty string.

It would be all the combinations. FireIce, FirePlasma, FireIcePlasma, etc…

You could check if they’re valid by checking if they’re in a structure. But I still don’t know if you can choose to have Ice or Fire or FireIce. If you you’re putting an object into a slot then also setting the matching variable.