Custom Projectile Plugin
This plugin allows the user to further customize projectiles. You can choose between several presets including: Sine wave, Orbiting, Boomerang, Arc, and further customize the parameters in built-in events. I have a couple ides for future presets, but leave a message if you have any additional requests.
There's an example game above to show off a couple of features possible with the plugin. In the Kiloman and Fortmania stage press Select to cycle between projectile types.
The plugin is free to use in your projects. As an added bonus for the kind souls who wish to support the plugin, you will get access to the project files to the example above. Credits are appreciated and I would love to see what you are able to do with the plugin.
1.3.0 - 2024-10-09
Added:
- Show and Hide All Projectiles Events
1.2.1 - 2024-10-09
Changed:
- Bitshifting for hookshot chain
- Can use both script execution and variable update
Fixed:
- Anchor type not breaking on switch statement
Download the zip file and unzip the contents in your projects plugin folder.
The resulting folder structure should be : C:\PATHTOPROJECT\PROJECT_DIRECTORY\plugins\CustomProjectile
There are currently two versions of the plugin. One that works for projects on 4.1.2 and above, and one that works on 4.1.1 and below. I will probably stick with 4.1.2 and above for future updates.
The plugin will not be compatible with other plugins that modify projectile.c and .h. You will have to manually merge them in that case. This plugin also modifies the projectile_t struct in gbs_types.h. So if there is another plugin that modifies the same file, you can simply copy over the projectile_t struct and delete the gbs_types.h file in this plugin.
After installing the plugin, simply add the "Custom Projectile" event anywhere before the "Launch Projectile" event, and fill in the desired values.
Projectiles Tab
Default: The standard projectile.
Arc: Create an arc trajectory, using the height and gravity parameters.
Boomerang: Adds a resistance value which will eventually make the projectile come back to the source. Play around with the speed parameter in the launch projectile event with different resistance value until you get your desired effect. You can also allow the projectile collide with the player if you want the projectile to disappear on return.
Sine Wave: Whip out your high school physics book and play with the amplitude and frequency of a Sine wave. Or add 64 to the phase and get a cool Cosine wave. If you're feeling fancy you can launch two projectiles with a difference of 128 making a double helix like pattern,
Orbit: Sine waves are nice but orbits are nicer! Specify an actor for projectiles to orbit around. If you want several orbiting projectiles you can specify their phase (0-255) to set their starting position. You can also adjust an X and Y offset to fine tune the center of the orbit.
Hookshot: This projectile type is the most involved and requires additional set-up by the user. The main projectile should be selected as head, which additional chain projectiles will use to calculate the distance from the head to the player. You can decide between having 0 to 3 chains in addition to the head. I recommend keeping the player stationary while the projectile is shot, and return control when the head collides with the player. The hookshot is based on states which can be controlled with the Set Hookshot State event. When launched the hookshot starts in the firing state, and can be set to automatically change to the "returning" state if it collides with a tile collision. If you want actors to be pulled by the hookshot you can set the state to "pull actor" when the actor collides with the projectile. Or set it to "pull player" if you want the player to be pulled towards the actor. Since the hookshot projectile ignores projectile lifetime, you will have to manually remove it. This is done using the "remove" state. You can add this to the projectile's collision with the player while also returning control.
Anchor: Anchors the projectile to an actor, making the projectile move with the actor. Setting the lunch projectile speed to 0 will allow the projectile to only move with an actor.
Custom: Not happy with the built-in presets? Make your own path! You can now control the X and Y deltas of the projectiles by specifying your own variables. These variable values can be adjusted in other events, so the sky is the limit here!
Properties Tab
The properties tab include more general settings for projectiles.
Infinite lifetime bypasses the lifetime of the projectile. There is a corresponding event "Set Projectile Lifetime" if you wish to toggle this.
No bounds allows projectiles to extend beyond the screen width and height, and will cause the the projectiles to wrap to the other side of the screen.
Gravity gives projectiles a downward (or upward!) momentum imitating gravity.
Collision behavior allows the user to select what happens when projectiles collide with tile collisions. You can ignore collisions, remove the projectile, make the projectile bounce off it, or only bounce off floor collisions. You'll want to play around with the speed and amount of collision tiles you have if you encounter any problems.
Lastly there's the ability to set a behavior when the projectile gets removed.
Update variables will set two user selected variables to the x and y coordinates of projectiles when they are removed.
Execute script will execute the user defined script when projectiles are removed.
Download
Click download now to get access to the following files:
Development log
- 1.2.0 Update51 days ago
- 1.1.0 Update52 days ago
- 1.0 Release72 days ago
Comments
Log in with itch.io to leave a comment.
Can i ask, how do i set up the plugin? I've been debugging for a while and the projectile just wont spawn. Do i need a string of scripts to spawn the projectile? I have it set on Anchor with 15 directional offset and remove projectile upon collision. What should i do?
Been trying it out, and it looks great, but for some reason it keeps using the wrong variables in my project.
For example, when the projectile is removed, I'm storing the projectile's position in global variables 30 and 31, but when checking the debugger, it stores it in some local variables on an actor that's in a completely different scene.
Using the custom behaviour type also doesn't work, as it's likely using the values from the wrong variables too.
Using a fresh project works fine at first, but changing local variables can mess everything up.
Additionally, I would also love to see the arc behaviour work in the vertical direction in Adventure and Top Down scenes.
Currently, it's doesn't seem to be taking into consideration the projectile's speed property when firing up or down.
(Using GB Studio 4.1.3, plugin version 4.1.2 and above)
Edit:
The offset values in the Anchor behaviour also don't seem to be accurate. It offsets it by roughly 1/3rd of the value I put in.
hi this looks neat. Can a projectile be made to bounce off things like a ball in breakout? thanks. also im using 4.0.0 and downloaded under 4.1.1 but got message: Plugin "CustomProjectile" is based on an unknown engine version and may not work correctly. Plugin authors can fix this issue by making sure `engine/engine.json` exists in the plugin containing at least `{"version": "4.0.0-e0"}`.
Is it possible to make a projectile that works like Super Mario Bros' fireballs with this plugin?
Does show/hide projectiles deactivate them or are they active but invisible?
Show/hide just turns off the rendering so they should still be active. There’s another event “Pause projectiles” that will stop them.
Does this work for top-down 2D games?
Should work in all scene types!
Arc movement on Projectiles is exactly what I need! Thanks for making these.
This is really impressive. Great work!
this allows so much stuff. thank you man!
Thanks for sharing these
These are amazing! Thanks for making these
Excellent work! Thanks so much for sharing this.