How to set up firing a bullet in different directions?

Good day. I have set up a 2D platformer player that can shoot up, down and straight ahead. I have adjusted the connector to fire the projectile from the correct position based on the animation. Everything works except the projectile only fires straight along the x axis rather than at the angle i would like it go. Any help would be appreciated.

Try the method from this post, it may help:

Thank you for the response but it was not helpful. I experimented with your suggested solution but it didn’t do anything at all. What I need should not require an outside function or plugin. I just want the player to shoot up ~45 degrees when I press up + shoot and shoot down ~45 degrees when I press down + shoot just like in a platformer run and gun. I just don’t know how to get it do that. I follow your channel on youtube and you have a ton of great info just not pertaining this. do you happen to have anything else?

It is possible through default visual scripting:

  1. You have to setup a VS structure like the image below so that you check what your visible_direction is and if any input (up, down) is pressed:
  2. You then will fire the respective bullet for each of those states utilizing OneDirection setting with the proper angle for that shot (straight can be shared because it utilizes FireObjectDirection and the player object should always either be 0 or 180 visible_direction):

「いいね!」 1

Thank you so much! that is precisely what I needed. so now I need to rotate the projectile and I am guessing your first suggestion is what I should use to do that? I did and it almost worked perfectly!

「いいね!」 1

Having an issue now with the bullets not flipping with the player. If you could show me how you have those links set up I would much appreciate it. I have tried various combinations and none have worked :frowning:

Ok in your situation and with current limitations for setting directions via variable (soon to be fixed in upcoming patches, but not available yet), I would do something different.

I would use GenerateObject instead of FireBullet, except for the straight shots I would keep FireBullet. I would then specify the starting action of the bullet for each direction:

Inside the bullet I would then set the bullet animation and direction of travel via DirectionalMove. If it’s straight (via FireBullet) then it will just take over the players direction, otherwise we specify the proper setup animation and direction of travel manually:

Hopefully that makes sense and gives you another option on how to show. Unfortunately you will need to manually control the bullets animation and direction in this case, BulletData won’t cut it in this situation.

thanks again but this isn’t what I asked for. I asked what your settings were for the states and connectors in your previous recommendation as I am finding where to place input triggers confusing. i did not really need an alternate option. I assumed that your previous advice was a tested and working suggestion. I am finding it odd that setting up a run and gun player would be so difficult in AGM. if we can go back to your previous suggestion and you can tell or show me what you set for the states and connectors that would be great.

The links for the original would look like this:

  1. If your firing bullet from like a child gun object (recommended) the link would be ‘is player pressing up’ AND ‘is player facing left (180 degrees)’:

  1. If your firing from the player object directly you can utilize myself, same conditions just using Myself instead of Set Object:

You would then do the same for each other direction, using 0 for right facing and 180 for left facing.

So I have set things up as you have suggested but things aren’t working and I am guessing it has to do with perhaps these three things - this is how I have the shoot trigger set up:

this is the direction check set up:

and this the set up for the specific states:

as it stands both L/R straight shots work fine, the up left shot triggers but not right, and both down shots do not trigger. I am thinking I did not set up the direction check correctly. If you would be able to take a look and see if I missed something I would very much appreciate it.

Hmm, seems like it should be working with your setup. Would it be possible for you to send in your project in a zip to our support email pgmmv-support@gotchagotcha.jp so we can look into why it isn’t working?

not a problem. What information should I send along with it?

Link to this post should be all that is needed, thanks!

「いいね!」 1

It is sent. Thank you so much for your help.

Incase anyone else was wondering, the issue was the link condition for the straight ‘shoot’ state. Since it was using the shoot input, which was priority, the solution was to include ‘not pressing up’ and ‘not pressing down’ inside that check.

「いいね!」 1

Yes it worked fantastically. thank you for all the help. here is the visual for the solution:

「いいね!」 1