Where We Left Off
Iâm developing a game independently, and the game Iâve built with Bakin is also published on Freem. Iâd love for you to play it, but you can get a good idea of what the game is like from this video:
In the previous article (linked below) we added damage processing for both the player and enemy characters when each takes a hit. In this article, Iâll explain how to implement ranged attacks such as a bow and arrow.
Implementing a Ranged Attack (Bow) in Bakin
In action games, melee attacks like sword swings and ranged attacks like bows or magic are both staples.
To give each type its own identity, melee attacks are often more powerful, while ranged attacks consume arrows or MPâthat kind of balance is typical.
Either way, ranged attacks are almost always necessary in an action game, so letâs implement a bow-based ranged attack.
First, prepare two casts: âRanged Attack Actionâ and âArrow Hitboxâ (feel free to rename them as you like).

For the âRanged Attack Actionâ cast, copy and paste the âMelee Attack Actionâ cast implemented in the previous articles to reuse it. Set up the cast event content as shown in the image below.

The playerâs motion uses the default âattack_C_01â bow-firing motion. After that motion plays, a âgenerate eventâ script spawns the âArrow Hitboxâ castâthe actual attack hitbox that flies toward enemies.
The âGenerate Eventâ script is extremely important for future game development, so I recommend taking the time to understand it through this exercise. After the arrow launches, the player regains control after a slightly longer pause than the melee attack.
That covers the cast event, but in the castâs âOtherâ settings, itâs a good idea to set a somewhat long disappear time under âElapsed Time.â Without it, the cast may disappear before the cast event finishes executing, causing bugs like the player getting stuck with their controls locked.

Next, the âArrow Hitboxâ castâthis is the arrow that actually flies from the bow toward the enemy.
Unlike the earlier hitboxes, set the âElapsed Timeâ disappear condition in âOtherâ to around 1 second (a longer value). Without it, the arrow will vanish mid-flight, which causes obvious problems.

The cast event for this one is very simple: it consists of just three scriptsâplay a sound effect, set the arrow to fly slightly above the ground, and move the event.

You can use any sound effect you like. The âChange Event Y Coordinateâ script fixes the Y coordinate (height) once set, so the arrow stays at that height from that point on.
This implementation means the arrow only flies horizontallyâto hit airborne enemies, the player must also jump.
Ideally the character would aim diagonally toward an enemy above and fire, but that implementation gets complicated, so this approach will have to do for now.
The final âwalk 10 tilesâ script determines the arrowâs range. You can increase it to â20 tilesâ or more if you want a longer range, but remember to adjust the âElapsed Timeâ disappear condition accordingly, or the arrow may vanish before reaching its full range.
Finally, set the movement graphic for the arrow. Without it, only an invisible hitbox flies toward the enemyâwhich doesnât make for much of a game.
Unfortunately, Bakin doesnât include a ready-to-use arrow graphic by default, which is something of a headache (honestly, something this basic should be included from the start).
For now, I used âmagicstickâ from the âSMILE GAME BUILDER Pack,â which Bakin recommends purchasing alongside the base game.
Honestly, anything that looks somewhat like an arrow can work here, even if it isnât intended for that purpose.
If you donât have the âSMILE GAME BUILDER Pack,â youâll need to find a free arrow-like image and register it as a resourceâa bit of work, but manageable.

Finally, add damage processing on the enemy side for when itâs hit by an arrow.
In the âDamage Processingâ sheet of âGoblin Aââs cast event, simply reuse the melee-attack damage logic and change the initial âCheck Contactâ condition to âArrow Hitbox.â Thatâs all there is to it.

Once everything is in place, run âTest Playâ and confirm the behavior matches your expectations. If everything is implemented correctly, the player should be able to fire an arrow that deals damage to the goblin when it hits.

Summary
In this article I explained how to implement ranged attacks in Bakin. Combined with the previous articles, you should now have a game that incorporates both melee and ranged attacks.
Iâll continue covering how to build more features in Bakin going forwardâcheck back if youâre interested.
đ Series: RPG Maker Bakin: Game Development Guide (7/17)