• 3D
  • How cautious should I be with projectile weapons?

I've heard that you shouldn't use guns that fire physical objects to detect hits rather than raycasts, because you have the odd chance of a bullet not actually colliding if it's fast enough. I understand this, but projectile weapons are nice for slower guns. How fast does the bullet need to be for this problem to occur?

One could equally argue that you shouldn't do hit-scan weapons for third person shooters because players can shoot from behind cover or around corners without ever being exposed. I think both statements are a kind of logical fallacy in that they can be true but only if you as a designer let that be true.

Of course you can use projectiles for weapons, they are called projectile weapons as opposed to hit-scan weapons for a reason. You just got to take care to model the collision properly so as to avoid such issues. It's a design problem.

For an example you could elongate your (invisible) collider along the path of the projectile modified by the projectile speed and average frame-rate or frame time in such a fashion as to avoid the issue of collision ghosting/skipping.

Be creative, it's what game design is all about.

edit: Another idea is to attach a raycast to your projectile and attenuate it's length by projectile speed and/or frame-rate so that your projectile couldn't miss the collision window. Lets call it the hybrid solution.

@OpinionatedGamer said: I've heard that you shouldn't use guns that fire physical objects to detect hits rather than raycasts, because you have the odd chance of a bullet not actually colliding if it's fast enough. I understand this, but projectile weapons are nice for slower guns. How fast does the bullet need to be for this problem to occur?

With my understanding of physics engines, the problem occurs if the bullet is moving fast enough to go through the entire collider in one physics step. So you could try to avoid the problem either by slowing down the bullet or enlarging the collider. In all my physics games I always make sure to have huge colliders when I can. My floor mesh might only be a 2d tile, but the collider for it expands a few meters below it. I do the same things with my walls. Actually for walls I make the whole back of the mesh big too even though you won't see it. This always prevents objects that might get suddenly flung at very high velocities from teleporting out of the scene.

I've never made this kind of game, but clearly the only solution is to change your player characters into really thick, really buff gym rats.

In bullet tunneling can still happen though even with CCD according to that post.

@xyz said: Looks like tests for kinematic bodies are always sweeps, so using them will most likely prevent tunneling. Situation with rigid bodies is dubious apparently. https://github.com/godotengine/godot/issues/9071#issuecomment-812956331

I could only skim through that article so long seeing people mentioning how Godot physics hasn't been a priority or how faulty it is. I had to shut that tab down. *Sips coffee. Ok back to my physics game!

@Erich_L Don't worry bananas and oranges in your game are slow enough. Tunneling would never hurt them. Unless you plan to include supersonic fruit launchers at later stages.

But seriously though, this is Bullet related and we can only hope that new physics engine in 4.0 will handle it with care.

@xyz said: @Erich_L Don't worry bananas and oranges in your game are slow enough. Tunneling would never hurt them. Unless you plan to include supersonic fruit launchers at later stages.

But seriously though, this is Bullet related and we can only hope that new physics engine in 4.0 will handle it with care.

@Erich_L , definitely add supersonic fruit launchers at later stages. Don't question, just do it!

@OpinionatedGamer , @xyz Without adding supersonic fruit launchers, could I face myself in the mirror in the fruity mornings to come?

@Erich_L said: @OpinionatedGamer , @xyz Without adding supersonic fruit launchers, could I face myself in the mirror in the fruity mornings to come?

I think if we are true to ourselves, we all know the answer to that. No you couldn't. When you grow older, you would look back on you life and say, "Why did I play it so safe? Why did I become a developer if not to push the fruity barriers? Why didn't I make supersonic fruit launchers!

Don't take your orange and go home, take your orange, AND YEET IT AT MACH 5!"

I'd exercise caution. It's not all peaches and cream. I'm sure you're cool as a cucumber but if you're just popping the cherry with mach 5 oranges implementation, have in mind that it's not a plum job. If you go bananas with feature scope, you'll inevitably upset the apple cart. And then the whole dev process could go pear-shaped. Take all this into account if you want to bring the project to fruition.

@OpinionatedGamer Well when you put it that way, I'll have to get on it right away. We'll see how thick I need to make my wall collision shapes to keep the mach 5 fruit inside. And @xyz you just won at forums.

@Erich_L said: @OpinionatedGamer Well when you put it that way, I'll have to get on it right away. We'll see how thick I need to make my wall collision shapes to keep the mach 5 fruit inside.

This could actually be a useful test, all joking aside.

a year later

I think if you are going to use physical projectiles, they should be slow so the player actually has a little time to dodge it. Otherwise, why bother? Just a leave a bloody hole decal or something with a big splatter.