How fast can a projectile fly?

Discuss anything ZDoom-related that doesn't fall into one of the other categories.
Post Reply
User avatar
Marscaleb
Posts: 23
Joined: Wed May 18, 2016 4:32 pm

How fast can a projectile fly?

Post by Marscaleb »

First of all, I mean this in general. Within vanilla Doom, ZDoom, other source ports, etc.

If I were creating a custom projectile, how fast could it travel before I could run into issue with it? Any sort of problem, clipping through walls, loss of accuracy... I don't know the inner workings of Doom so depending on how projectiles work there are a lot of ways it could go wrong.

I'm thinking along the lines of having all weapons fire projectiles, so even a hitscan weapon that shoots bullets would shoot a projectile, just a really really fast one.
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

Re: How fast can a projectile fly?

Post by Arctangent »

About 60 for a large, regular projectile - somewhere around that point and you get weirdness with vertical movement.

However, as a general rule of thumb, a projectile shouldn't move much faster than twice its radius. At that point, it becomes possible for the "steps" a projectile takes to have spaces in-between each other, allowing for the projectile to fly right through things. A small amount of this space doesn't matter all too much for actor-on-actor collisions, since other actors generally won't have hitboxes small enough to fit inside that space, and I think it might not matter at all for actor-on-line collisions ( though don't quote me on that ), but too much of a disparity can cause issues.

That all said, there's a [wiki]FastProjectile[/wiki] class that actors can inherit from that eliminates these issues in most, if not all circumstances. FastProjectiles don't come with all of the features of normal projectiles - for example, they can't bounce last I checked - but if you're just replacing hitscans with really fast projectiles, this shouldn't be much of an issue.
User avatar
Marscaleb
Posts: 23
Joined: Wed May 18, 2016 4:32 pm

Re: How fast can a projectile fly?

Post by Marscaleb »

Ah, see, the "steps" thing is exactly what I was worried might happen.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: How fast can a projectile fly?

Post by Matt »

FastProjectiles are theoretically unlimited since they'll do as many collision checks as are required every tic to fill in the gaps, but they can be a performance killer with lots of very small, very fast projectiles (e.g., real-life bullets which are smaller than 1 DU and go at over a thousand DUs per tic) which is what this is for.

For fancy physics stuff, you could try adding them manually to a FastProjectile-derived class, since virtually the entire FastProjectile's movement code is editable in ZScript. (Gravity, for instance, can be added by calling "vel.z-=GetGravity();" every tic.)
Post Reply

Return to “General”