How do i make it where i can only shoot when i have enough arrows for my bow?

I really need help with this,.

1 Like

It’s hard to help with so few details. But you can use a filter behavior (if the arrow amount is greater than 0) before you shoot/emit/spawn an arrow.

1 Like

Ok so i got a little confused

20 has to go into the filter…

I also have a Gun Example:

ok i fixed it but i need to make it where if you have 0 arrows, it wont let you shoot arrows

like when it goes to zero, its where i can still be pressing the button and the number still decreases

i can help.

1 Like

Thanks! Im new to making rpgs, espaically in platformer, so thanks!

1 Like

3 Likes

And no problem, this should help you.

1 Like

how to replenish the arrows one by one by collecting an item?

3 Likes

I don’t have a working example to share, but basically if my understanding is correct, you will want to create an item that will add + [number] to your arrows when your character collides with it (and also make sure the item gets destroyed after, otherwise the character will be able to collect infinite arrows).

3 Likes

Actually I do have something somewhat similar…

It’s an unrelated game to what you’re making, but when my player character collides with fish, it adds to the “food” number… basically you will need a collision block set to a “get” number and connected to the + arrows number.

3 Likes

WOW! thanks for the advice. SO here’s the issue, everything works except this concept.
I have to pick up one item to replenish my spell capacity and later to use it against monsters. In short, I pick up an object and i use it as a spell to shoot an enemy and if my ammo has run out then i should stop shooting.
Can you please help me here? If this is fixed my game concept is done!.

3 Likes

I’m still pretty new at this stuff, but that shouldn’t be too hard to code…

I’m thinking you will want a filter and a switch. A filter to check that your ammo is greater than 0. Pass, it turns the switch on. Fail, it turns it off.

Then you will have to run your “shooting” thing through the switch.

Essentially you want to disable your ability to shoot once you run out of ammo.

Off switch to the emitter. I’m thinking you will want to link your shooting key to the “in” position of the switch, then have the “out” go to the emitter. That way when it’s turned off, it shouldn’t emit.

Though I’m assuming you also have it set up to -1 arrow every time the arrow shooting key is pressed. You want to make sure that is set to not go below zero, otherwise you could end up with -999 arrows by pressing the key too many times.

Easiest way I have found to solve that is to connect a filter to the “arrow” value… say I want the max number of arrows to be 100 and the minimum to be 0, I set a filter “greater than 100” to a “get” 100 value rerouted back to the arrow number (or is it set? now I don’t remember for sure). Do the same with another filter on “less than zero” to reset the number at 0 to avoid having a negative arrow balance.

There might be an easier way to do it, but that’s how I’ve made mine work so far.

1 Like

Not sure if this helps, as it’s what I used for a timed speed boost when holding down a key, but it’s the same general concept, you just need to adjust it for individual key presses rather than time…

When the stamina bar runs empty, the player character can’t speed boost any more until it recharges. But I also made sure that pressing the boost key will not drive the stamina bar into negative by holding it down after it’s empty, by adding a filter to set the “minimum” value at zero.

I hope some of this makes sense.

2 Likes

Your first advice giving, good job TGW.

1 Like

Just passing along some of the tricks I’ve learned. I’m always happy to share knowledge once I have it.

2 Likes