Projectile weapons with ballistic trajectories

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

SoSilencer

Harry Goz (1932 - 2003)
Nov 27, 2000
834
0
0
42
unrealdev.net
Making "proper" ballistic weapons is hard. I mean it seems easy enough, just make a phys_falling projectile with an extremely high velocity, but there are lots of problems you run into. Maybe somebody knows how to fix this...

First problem is shooting the ground or anything nearby. The projectile hits and gets destroyed before it's replicated. You can fix this by temporarily 'hiding' the projectile from players for a couple seconds after it hits, thus giving the projectile time to replicate, and although this works it isn't such a great solution. Then you have a velocity problem. I've never been able to figure this out so if anybody has any ideas please let me know. Proper ballistic projectiles will have a speed ranging from about 14,000 to 45,000 units per second. The default max velocity for zones and volumes is 2,500. If you make a new volume with a high max velocity such as 65,536 it works fine offline but online the projectiles seem to be limited by the default limit of 2,500. This doesn't make sense because you've made a new volume in the map with a high velocity and everything works right offline but sure enough, it just doesn't want to use the higher velocities online.

If you manage to fix that (let me know please) you then have another problem. Since the projectile is (at least should be) spawned by the server the velocity is so fast that by the time it reaches the client it's very far away already. If you have a tracer or special effect it starts way out from the player rather than from the muzzle of the gun.

There are probably a few other problems but those are the ones I can think of.
 

Cowboybot

High Voltage
Nov 28, 2002
1
0
0
Visit site
Rachel

Man! I have been searching for this for Ages, Thank you thank you, thank you, maybe I can complete my energy rifle.

once again, thanks.
 

Mychaeel

New Member
I actually doubt that making a fast-moving "ballistic" projectile in practice really gives you the trajectory or "feel" you're looking for.

Since there's (most likely) no means built into the engine to actually make an actual parabolic trace, I assume any moving actor that's subject to gravity has its trajectory simulated on a frame-by-frame basis like this:

  • First, the engine calculates how far the projectile could have moved at most given the elapsed time since the last frame and its current velocity.
  • Then, a linear trace is done from the projectile's old position to its calculated maximum end position. If it hits an obstacle, the end position is corrected accordingly.
  • Lastly, the projectile's velocity is updated to accommodate gravitational pull (again given the time since the last frame and the effective gravity).

So, actually, instead of getting a true parable, you get a rough approximation of one made out of straight segments.

For slowly moving actors that's not a big deal and the trajectory still looks nicely similar to smooth parable, but for very fast projectiles the effect is only little different from "instant hit" depending on the distance to the target. For a projectile with a speed of 45,000 units per second and assuming a server tick rate of 30 ticks per second, anything closer than 1,500 units (corresponding to about 30 meters) will be hit exactly like with an "instant hit" weapon.

The downward velocity induced by gravity, in turn, is little more than 30 units per second per tick. Assuming that 5,000 units roughly correspond to a distance of about 100 meters, the projectile has gained less than 100 units per second downward velocity when it reaches that distance (given the default gravity of 950 units per second per second as defined in PhysicsVolume); a negligible amount compared to the 45,000 units per second initial velocity.

In conclusion: I wouldn't take it for granted that making weapons with fast-moving projectiles effectively makes any perceivable difference in how weapons "feel" in the game. It's your individual call, of course, but maybe the hassle of implementing those projectiles properly and without any unwanted side effects is actually not really worth the trouble.

[edit]
Of course, you could get around the maximum velocity limitations of the game by implementing your own projectile movement code along the lines of what I described above; while doing that in UnrealScript rather than letting the engine do it is somewhat less efficient, it's a matter of only a few UnrealScript statements that are executed per tick and thus should not have noticable impact on performance.

[edit]
Taking the measurements on Unreal Wiki: General Scale and Dimensions as a guide (50 units approximate 1 meter), the standard gravity of 950 units per second per second is way off as far as realism is concerned; it should be more along the lines of 500 units per second per second. That halves the vertical velocities I was talking about earlier, making the effect even less perceivable.
 
Last edited:

SoSilencer

Harry Goz (1932 - 2003)
Nov 27, 2000
834
0
0
42
unrealdev.net
You are right that a faster projectile isn't really different from a simple trace for most ranges. The benefit comes when using projectiles of varying velocities. For example an M16 would have an in-game muzzle velocity of just under 45,000 units. A supressed p90 would have a velocity between 14,000 and 15,000 units. When switching between the weapons the trajectories become very noticable. Even if you just switch between something of say 35,000 units and 40,000 units, the medium and long range trajectories are different enough that the guns really feel different. It is very noticable when dealing with several different projectile speeds.

I just wish I knew why in online play every reverts to a 2,500 max velocity.