I was thinking of making a railgun in the game if i can get the hang of coding. Would really high speed projectiles encounter problems? I have only 'modded' one game before and setting really high projectile speeds caused rounds to go through players and the terrain because the collision detection messed up.
All you need to know is the tickrate of the projectile simulation and the smallest unit/terrain hitbox. For there you can work out the maximum theoretical speed for a projectile to not phase through solid matter. The theoretical speed of the projectile cannot exceed [x] units of distance per tick of the simulation where [x] is the shortest diameter of the smallest unit or terrain hitbox. However I'd set it quite a bit lower than that... Simulations have a habit of being coded to skip a ticks under heavy load to decrease the number of calculations handled by the server
That is assuming they use simple Euler interpolation and only calculate collision going off position.
I've actually worked on very-high-speed collision detection, and there are a number of methods to do it. For a single point object, it's simple enough. But once you get to shaped objects, things start to get complex. (And lots of math starts to surface.) In any case, getting it working properly in a game would require that it be built into the game code from the start. Otherwise you will only end up with approximations. Also, you have to realize that the system will be hugely affected by netplay, and lag will end up causing your system to bug up no matter how efficient you write it. In this case, the better solution would be to "pretend" that your projectile is moving at very fast speeds, but in reality, make it only fast enough that an ideally moving target has no chance of dodging it within a limited timeframe. Berthas in TA would actually be pretty hard to dodge if they were 100% accurate, because even on larger maps, the projectile travel time is shorter than the time it takes for most units to move away from the point of impact.
The size difference between the projectiles and the units is probably large enough that there's no point factoring in the size of the projectile and you could just use a ray cast instead which will not have the same speed restrictions for reliable hit detection.
It really depends on the application, but recall that not all projectiles modeled will be instantaneous, just very fast. Take, for example, the Sonic the Hedgehog games, for Sega Genesis. (Which had a very impressive game engine, in my eyes.) Sonic can move at very fast speeds ingame, but it's never instantaneous. It is, however, fast enough that per-tick collision detection would result in him going through walls. This means that his position needs to be interpolated between frames to ensure that all areas in between are tested too. This issue would be compounded in a 3d world, especially at the sizes supported by PA. A railgun that hits its target instantly from across the planet wouldn't feel right, especially for larger planets. So it would need to be implemented as a very-fast-object, and that's where these considerations come in again.
I am by no means a modder (although i have written a little bit of python), but could you not just modify a laser to do a hole lot of damage over a very short amount of time? It seems like the simplest solution to me, assuming of cource that there will be instant hit lazorz in the game!
So basically a hitscan weapon as already covered? In short making a weapon that's supposed to be a high speed project a hitscan/function akin to a SupCom style Beam are just workarounds, given that the game/engine is based around the idea that things like this are supposed to be simulated making it work as intended is the best outcome and only falling back to the workarounds should the ideal method not be possible for whatever reason. Mike
Well, if you're designing a weapon that is SUPPOSED to hit 100% of the time, what's the point in simulating it? Just do hitscan. I mean yeah, I get it if the projectile is actually supposed to miss on occasion, but the ranges and situations in which it would actually miss are very, very sparse. Then again, the mod I'm going to be working on is going to have simulated projectile coilguns, so I should probably just shut up.
An object traveling at high speeds may not be intended to hit 100% of the time. Remember that the speeds at which certain projectiles are fired will need to be fairly substantial given the scale of PA. PA's version of a Bertha will need to travel very quickly in order to travel across a large planet in a reasonable amount of time, more so if it travels at inter-planetary distances. A projectile with a relatively slow travel time of 1 second to reach its target would still be going quite fast, according to ingame units. It certainly won't hit 100% of the time, but special considerations will definitely need to be taken to ensure proper collision detection.
You realize that a "hitscan" (which is really just a ray cast) need not be infinite right? You just do a ray cast between where the projectile is and where it should be next frame and if it doesn't hit anything you update the projectile position for the next frame, simulating a proper collision hull is a terrible way to handle projectiles, it's highly unreliable and even more inaccurate. IMO if a projectile is small enough and/or fast enough that you cant always be 100% sure that it visibly clipped through the target model then ray casting is the only way to simulate that projectile's movement, and in PA all projectiles would fall under that category.
I would prefer not to use hitscan as i would think the weapon would be a very long range weapon and having what is basically instantly hitting high powered artillery would be slightly unbalanced.
Every single physics engine has limits that will break it. Typically you have to find the limits empirically in a game engine.