I Need Help With My Attacking System

In my game I have it to where there is this red bubble around the player that grows and shrinks. I want the player to be able to press Space while the bubble is over the enemy and then destroys it, how can I do that?

1 Like

You could make the bubble have a proximity that detects for enemies and there is an option where the entire enemy object has to be completely inside the proximity to release a signal. Which you could link that up to an AND gate along with the Space key (with repeating) and when the enemy is within the bubble and you press space you have to send a message to the nearest enemy object and that message can destroy the enemy.
I think that should work.

Even easier, if your bubble is physically growing in size (i.e. you are using a number block to adjust the size and not creating an illusion with an animation), you can simply add a switch to the enemy that turns on when it contacts the bubble, then allows space to pass through and destroy it. Then add a continuous timer to turn off the switch if the player doesn’t hit space bar.

1 Like

Can you show me an example?

Here is what I tried to do Flowlab Game Creator - Shroomland

For the Bubble:

For Enemy:

I think this is similar to what Bmarzi said, but I was a little confused on the switch part, lol.
Anyway you want to make the bubble Enable Collisions so the enemies can actually collide with it. Then you might want to rename it, cause at first I though it was Attack Bubble and not New Type 28 so I had to look around the objects a little bit.
Also the Global you want to set it up to some sort of command block that adjusts its size and you want to set the global to 100% or anything above 0 at first load up of the game so the bubble doesn’t completely disappears.
Hopefully this should work.

Oops, I forgot you needed to press Space again, lol.

1 Like

So that’s what Bmarzi said about the switch.

Anyway you want to have a Space Block on the enemy that is connected to the IN of the switch. Then you want to have the proximity from the enemy that is detecting for the bubble to go into the ON for the switch.
The next part will be a bit tricky since you want to connect a NAND gate to both outputs from the proximity so that way it can detect when the proximity isn’t detecting anything and it will release a signal. Sometimes the NAND gate won’t work so you can use the NOR gate, but only take ONE output of the proximity and put it into ONE input for it. That’s only if the NAND doesn’t work.
Anyway you hookup the output of the NAND or NOR gate into the Switches OFF input so that way the switch will turn off when the enemy isn’t in range so that way you can’t kill off the enemies that aren’t within the bubble.

Hopefully this should help now, lol.

So this?

1 Like

Yeah that looks about right, does it work for you?

It’s not working for me.

Cause you used the object Attack Bubble. I looked through your objects and the bubble you are currently using is called New Type 28. Maybe rename that object to just Bubble or just select that exact name.

Wait, couldn’t you use ray-cast instead?

You could use raycasting, but for a situation like this I figured that proximity would have worked better, but if you just doing a platformer based game then raycasting would probably still work.

When I use NAND and NOR it doesn’t work. It just keeps turning the switch off

What is the specific object that you are using for the proximity?
NOR and NAND do work, but they are very picky and they do bug out a lot so I wouldn’t be surprised if you are experiencing issues with them.

New Type 28

Okay, this is very complicated.

The reason it’s not working is because when I checked it out myself I deleted all of your code cause I didn’t know what it was.
At the beginning of the game the bubble will expand a little but until the player loads in then it shrinks into nothing. You might want to bundle your code and throw it into a spare object in case you need it later and delete it from the bubble object and place the code I showed above.
Or you could edit what you already have to prevent the bubble from shrinking right off the bat.

Then everything should work, the only reason the proximities, NAND, and NOR gates are picking it up because the bubble went subatomic. So if you can somehow prevent the bubble from shrinking into a cell then it should work out.

What do you mean “into a cell”

It shrinks into nothing, thats what I meant.