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.
It’s not Far Cry, nor Crysis, but it could be. The Realistic Jungle Demo demonstrates that Godot is capable of impressive visuals. If you want to run it yourself, download it from https://wrobot.itch.io/jungledemo. It was announced in this Reddit post. Update: The source code was released (with the commercial assets removed).
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
Inventory System v1.2 available
A few new features: Bug fixes:
Inventory System v1.7 available
A couple of corrections and a new feature: Bug fixes:
Fire, Rain, and Black Hole particle effects
This video is from December last year and uses Godot 4.0-beta7, but I thought it was interesting, because… particle effects!
The Godot Jungle Demo
It’s not Far Cry, nor Crysis, but it could be. The Realistic Jungle Demo demonstrates that Godot is capable of impressive visuals. If you want to run it yourself, download it from https://wrobot.itch.io/jungledemo. It was announced in this Reddit post. Update: The source code was released (with the commercial assets removed).