Ever had the problem where you’re firing a bullet or some kind of projectile at high speeds, and it just goes right through the collision object, instead of hitting it?
Here’s a weapon that fires a bullet at random velocities, to demonstrate the issue:
The bullets impact the character in various places, rather than at the first point of contact. I haven’t found a way to enable any kind of continuous contact option, outside of playing with the
safe_margin
setting. I ended up adding a raycast:
It’s definitely a hack, though. The
move_and_collide
should be replaced by the ray query. Using both instructions together could result in an even weirder situation;
move_and_collide
could skip a collision object (the issue we’re trying to fix with the ray query), but then still collide with a different collision object. Then the ray query redoes the same movement and collides with the first object that was missed by
move_and_collide
. Depending on the game, that could mean something like randomly shooting through shields or walls under specific circumstances.
The current approach is essentially a two-pass solution, where the first pass is sloppy, and the second pass works as intended, but doesn’t move the projectile.
Need optimized export templates with PCK encryption support but don’t want to have to set up a build pipeline or download the entire compilation toolchain on your computer? Well, now it is. Fill out the form, checkout, and we’ll email you the download link after the compilation completes. Compilation may take 30 minutes to 3 …
New to Godot Engine? Want to get started creating awesome games quickly? Just use AI! AI learns (is trained) from online content (which is a whole separate topic). As a result, the quality of the answers the AI provides is based on the volume and variety of content available to learn from. Since Godot is …
This release finally uses Godot Engine 4.4. It adds the GGCraftingSystem singleton and updates the GGInteractable2DStrategyCrafting class to use it. The crafting editor nodes now have prefixes, which makes it much easier to search for specific recipe or item nodes in larger crafting libraries. Some syntactic sugar was added as well. You can now easily …
Just a couple of days ago, Godot 4.0 alpha 17 was announced. Today, Godot Engine 4.0 beta 1 was released. Be sure to check out the announcement. There are lots of improvements across the board; rendering, lighting, physics and navigation, animation, and scripting.
Projectiles going through collision objects
Ever had the problem where you’re firing a bullet or some kind of projectile at high speeds, and it just goes right through the collision object, instead of hitting it?
Here’s a weapon that fires a bullet at random velocities, to demonstrate the issue:
The bullets impact the character in various places, rather than at the first point of contact. I haven’t found a way to enable any kind of continuous contact option, outside of playing with the
safe_margin
setting. I ended up adding a raycast:The ray cast looks somewhat like this:
It’s definitely a hack, though. The
move_and_collide
should be replaced by the ray query. Using both instructions together could result in an even weirder situation;move_and_collide
could skip a collision object (the issue we’re trying to fix with the ray query), but then still collide with a different collision object. Then the ray query redoes the same movement and collides with the first object that was missed bymove_and_collide
. Depending on the game, that could mean something like randomly shooting through shields or walls under specific circumstances.The current approach is essentially a two-pass solution, where the first pass is sloppy, and the second pass works as intended, but doesn’t move the projectile.
Related Posts
Introducing GodotBuilder: Custom Export Templates built on demand
Need optimized export templates with PCK encryption support but don’t want to have to set up a build pipeline or download the entire compilation toolchain on your computer? Well, now it is. Fill out the form, checkout, and we’ll email you the download link after the compilation completes. Compilation may take 30 minutes to 3 …
Creating games with Godot Engine using AI
New to Godot Engine? Want to get started creating awesome games quickly? Just use AI! AI learns (is trained) from online content (which is a whole separate topic). As a result, the quality of the answers the AI provides is based on the volume and variety of content available to learn from. Since Godot is …
Inventory System 2 Alpha 4 available
This release finally uses Godot Engine 4.4. It adds the GGCraftingSystem singleton and updates the GGInteractable2DStrategyCrafting class to use it. The crafting editor nodes now have prefixes, which makes it much easier to search for specific recipe or item nodes in larger crafting libraries. Some syntactic sugar was added as well. You can now easily …
Godot Engine 4 reaches beta
Just a couple of days ago, Godot 4.0 alpha 17 was announced. Today, Godot Engine 4.0 beta 1 was released. Be sure to check out the announcement. There are lots of improvements across the board; rendering, lighting, physics and navigation, animation, and scripting.