Have Player shoot on key press

I went through the various tutorials, and even some Youtube videos and I’m sure it’s something I’m doing wrong and not being a coder and just learning this, I’m sure I’m missing something very easy.

I’m trying to get a player to shoot a “bullet”. I’ve also assigned a custom point to create the object.

I also have a button for mobile platforms to simulate the pressing of the key as well.

I have assigned specific animation when the fire button is pressed (same for both mobile and desktop) and the animation does work as expected, just nothing being fired.

Any thoughts?

I’ve attached the main keyboard “code” and the custom point on the player as well that was created to where the “bullet” is generation. Thanks!!

Event%20Code|690x126

Sorry for the extra post, apparently newbies are only allowed 1 image per post.

Mine is set up something like this… (my bullets in this case are band-aids)…they shoot in four directions, but I could only capture events for two. You may have to add variables to your objects, the scene, or globally depending on how you want to handle the inventory. I have mine displayed on the GUI so it has to keep track of quantity and if it’s empty, which is a whole other set of events.

Mine is very basic. No inventory, would like to setup it up to where it’s just one shot before the next one can be taken, but need to get it to where something delivers.

I’ve tried the various tutorials and their lines of conditions/events, the one pictured was just the last one used.

I see where you have the force of the bullet in 2 directions (I only need one as it’s only coming from one spot and I’m not having it flip or anything like that), again very basic to try to get something.

I don’t know. Thinking that maybe order of the event/conditions compared to other event/conditions, I have everything as external events and I link them into the main game event sheet to make it easier for modifications (such as changing the order in how the appear). I would like to think I have some logical thinking skills, but after 3 hrs I thought it was best to try here.

EDIT to ADD: Just for frame of reference this is the game scene. I have it to where it’s like asteroids, go off the screen, show back up on the other side. Player is on the left, enemies are on the right. The buttons along the bottom are only visible on mobile. The cannon button is also a fire button. Animation works for the fire buttons, but no object is created. I wanted to have enemies automatically randomly generated, but that was another item that I couldn’t get to work right, but “firing” is the more pressing, then automatically generated enemies (but that’ll be another post I’m sure).

Most of my events are on external sheets as well; the weapons events are actually in a function and applied as a custom action. The different directions don’t matter that much. It’s just a working example; you can use whatever you need, leave out what you don’t.

I don’t use Points – it’s just player.X() and player.Y() – maybe that’s fine for my game but not yours. We’re also using slightly different actions to add force - I think you’re using “Add a force (angle)” whereas I’m using “Add a force”.

Have you tried that already?

It’s difficult to say what’s interfering with your bullet creation without seeing more events.

You may still need some variables, even if they aren’t called “inventory”. You could still do that without displaying it anywhere though, to tell the game what to do when the player “hasBullets”.

Hopefully, the rest of them would show up in this one, I was trying to get them all in one since I’m limited to one pic per post for the time being.

I did include the keyboard event sheet again as I had swapped out to just regular “add a force”. Everything else works (some of it I would refine later on, enemy behavior especially, this was more about getting things up and running).

Do you have an “at the beginning of the scene” condition in there anywhere?

I’m not sure if it’s on another sheet that wouldn’t fit in the picture (thank you for doing that by the way). If you don’t have it, I’d add it before those events even if you do have it in your main event sheet. Sometimes the solution is as simple as that :slight_smile:

If that doesn’t work, my next step would be to try a simple scene variable, maybe called “fire”.
I’ll attach an example from the editor if needed later.

I have “At the beginning of the scene” it was on my main scene event sheet (the rest are links to the external events that I’ve posted. That’s all the “code” that I have in the game so far.

maybe if you could share a zip with your project folder we can take a look amd help

I feel like an idiot.

Because I resized the player on the stage and not within Piskel (if it’s possible, I see the resize drawing area, but not the actual graphic file itself, probably have to go back in Krita to do that) or just were it would also update the custom firepoint, that’s what kept it from firing.

Once I kept the original size and just put in the same code as before, I was able to get bullets.