GDevelop-extensions
GDevelop-extensions copied to clipboard
New extension: Bounce Raycasts
Description
This extension adds the functionality to simulate bouncing raycasts with a maximum amount of bounces set by the user.
How to use the extension
This extension adds 3 actions:
Bounce raycasts
- simulates bouncing raycasts with a maximum amount of bounces.
Bounce and draw raycasts
- simulates bouncing raycasts and immediately draws the bounces using a shape painter object.
Draw raycast bounces from a variable
- allows the user to draw the bounces from a previously saved simulation using a shape painter object.
The raycast results are stored in a structure variable.
Checklist
- [X] I've followed all of the best practices.
- [X] I confirm that this extension can be integrated to this GitHub repository, distributed and MIT licensed.
- [X] I am aware that the extension may be updated by anyone, and do not need my explicit consent to do so.
What tier of review do you aim for your extension?
Community (Unreviewed)
Example file
Extension file
I realised how to add one feature. If anyone is currently testing this, give me a moment.
!update BounceRaycastsExample.zip
❗ No updates found. Please check your file.
Stupid bot, Updated example: BounceRaycastsExample.zip
Updated extension: BounceRaycasts.zip
Sometimes the ray might not hit the object. I updated the extension so that it checks for that. If the ray doesn't hit anything, the extension will calculate the end position of the ray.
Thank you for submitting an extension.
Are you using this extension for your project? If you have a public build or some gameplay footage, feel free to add links. It will help reviewers. Please do a list of all the use cases that comes in mind, for instance something like "Show a trajectory when players aim".
https://github.com/GDevelopApp/GDevelop-extensions/assets/105156446/c7cd4be3-acde-456d-bdb9-12da5dab597d
https://github.com/GDevelopApp/GDevelop-extensions/assets/105156446/2faf64c0-d6a3-4fac-958a-1d274234be2c
https://github.com/GDevelopApp/GDevelop-extensions/assets/105156446/937bfe35-a591-48ba-afda-5ea6263497ed
I also updated the extension to include 2 more things: Obstacle angle (used for the platformer example) and a toggle to check for the total distance travelled by the ray instead of a per bounce basis. Useful when there should be limited distance because normally each ray is separated.
The second ray example:
https://github.com/GDevelopApp/GDevelop-extensions/assets/105156446/0b241b3e-177b-4dee-a2c1-9a0153082879
I also really wanted this extension to check grenade throws in one of my games. My solution back then was to just simulate all of the possible grenade throws. This will allow for a much easier and faster way to do this. https://twitter.com/AppthonyGames/status/1736026269689532895
Thank you for the explanations.
If I understand correctly, the main purpose of this extension is to:
- predict a tiny projectile trajectory with bonces.
It allows to:
- show an aiming aid
- help to make AI
Limitations:
- It can only be used with tiny projectiles
- It can't be used with the Bounce extension because the trajectory won't match
Do you see something to add or to correct?
I tested the bounce extension, the trajectories do seem to match somewhat well. It's more to do with the fact that a raycast doesn't use a collision mask, so the trajectories will change because of that. It does seem to adjust and go a little offsync repeatedly. Sometimes it's pretty much spot on, sometimes (most likely due to tilted walls) it seems to skew a little but it also seems to slightly return to the ray trajectory over time. Generally it does a pretty neat job at predicting bounces (I tested this on a square with a resolution of 10x10).
What a person can do to guarantee accuracy is this:
Index starts at -1 (because for some reason it increments it by 1 automatically), it will properly follow the trajectory up until the bounces end, then it goes to 0;0 but that's easily fixable.
I updated the extension to support shapecasting too. AdvancedRaycastAndShapecast Example.zip AdvancedRaycastAndShapecast.json