Bullet speeds in a space shooter

Blitz3D Forums/Blitz3D Beginners Area/Bullet speeds in a space shooter

lo-tekk(Posted 2005) [#1]
I encountered some flaws in my gameengine regarding bulletspeeds. In most sample codes you will find that bullets regardless of the shooters speed are moved at a constant rate. But is it not true that you have to add the shooters speed to the bulletspeed at the time a bullet leaves the muzzle ? In fact in both cases as i accelerate the player ship along its z-axis the optical length of the way the bullets travel across the screen vary. This looks odd. I hope i have made my problem clear enough. If anyone has a idea how the speeds should be computed correctly please help.

Thank you


Rhyolite(Posted 2005) [#2]
I beleive what you are saying is correct, unless you are firing lasers at the speed of light ;) Most games do not concern themselves with firer speed because the speed of a running man is inconsequential to the speed of a supersonic bullet.

So, yes, add your vehicle velocity to bullet velocity. This is why when you jump up on a bus or train you do not hit the back wall!!

Rhy :)


Damien Sturdy(Posted 2005) [#3]
Rhy, Good words.. However, While i dont hit the back wall, I do tend to hit the Bus mirrors or roof :P (im tall :/)


lo-tekk(Posted 2005) [#4]
Thank you Rhyolite,
i will stick to this. I also have reduced the overall playerspeed and raised the travelspeed of bullets. Looks okay for now.


jfk EO-11110(Posted 2005) [#5]
As Rhy said, supersonic speeds are higher than the speed of sound, that is about 950 km/h (depending on weather etc.). small bullets may travel with this speed, rifle ammo goes up to 3*sonic speeds. I have no idea how they funtion in space - and you also need to consider the speed of the ship, that is a lot faster than a walking man, or a bus. Spaceships may accelerate continously to something like 30'000 km/h, so they are much faster than a bullet - you even couldn't hit them with a firearm. I think in space you'd need to use rockets that are accelerating themselfs too.

Imagine the worlds surface moves/rotates at about 1600 km/h, so when you shoot a supersonic rifle bullet in the opposite direction, the bullet may just float in mid air.


Rhyolite(Posted 2005) [#6]
Ohhh, I love physics!

"Imagine the worlds surface moves/rotates at about 1600 km/h, so when you shoot a supersonic rifle bullet in the opposite direction, the bullet may just float in mid air."

I assume this is what you meant, but just to clarify, this would only be true when the 'viewer' is not rotating with the planet (ie. from space).

In fact the bullet could also appear to be going backwards (depending on velocities), but the gun which fired the bullet would appear to be going backwards even faster (in fact, at the same speed as the surface of the planet, unless of course the gun was carried by someone who was running or on a bus and jumping in the air.....!!).

Lol!

Rhy ;)


lo-tekk(Posted 2005) [#7]
This gets funny, in X2 i sometimes ran into my own rockets from behind, because i had greater speed. The easiest weapon in my game in terms of pyhsics was the disruptor beam thing, since it travels at lightspeed it means an instant hit by just spanning the sprite/quad from player to target.

------------------------
www.moonworx.de


Rhyolite(Posted 2005) [#8]
Ahhh, but...

A disruptor beam (laser) travels at the speed of light. So, when fired from a ship travelling at 1/10 the speed of light, how fast is the beam travelling?

Or, if you were in a ship traveling at the speed of light and you turned your headlights on - what would happen!!?

Rhy ;)


markcw(Posted 2005) [#9]
according to a nasa article i read once,
since there is no air resistance in space
something given a constant velocity,
like a bullet, could never slow down
until it hit something.
in fact, i believe it would continue to
accelerate a little bit all the time. iirc


_PJ_(Posted 2005) [#10]
Yeah, objects moving in space continue with constant velocity because there are no forces acting on them.

As Rhyolite says, most games ignore the speed of a man running when he fires a gun because the 10miles an hour or so of the man sprinting is negligible compared to the speed of the bullets!

I think the easiest way to deal with fast bullets is not to make things actually move, but just use Linepicks to see if a line from the gun muzzle hits anything. This gives instantaneous shooting.



when you start dealing with objects moving at light speed, it gets rather complex because the observed speed of light is constant regardless of the speed of the observer. This is very difficult to explain or program ;)


------------------

Lo-tekk, what sort of game are you making and what effect do you want to achieve?

It's very popular to abandon real-life physics and stuff in a lot of cases for playablility reasons!


lo-tekk(Posted 2005) [#11]
@Malice,
should become sort of Privateer, Freelancer, I-War II etc. thing but with top down view. There's still a long way to go. The weaponeffects are working now good enough. I had the problem that i don't wanted to collide with my own gunfire while accelerating the ship.

-------------------------
www.moonworx.de


Nicstt(Posted 2005) [#12]
gravity from local celestial bodies will have an effect, can use to both speed up and slow down an object.


_PJ_(Posted 2005) [#13]
Glactic Also suffered from a similar problem, in trying to make the bullets travel fast enough so as to be faster than the ships, and even always appear faster, I encountered some z-buffer issues or floating-point errors resulting in the bullets even travelling backwards!!!

With 3D movement, momentum and drag effects affect the actual forward motion of a craft whjen it is turning, therefore it can get quite complicated when trying to work out the trigonometry required to add the forward velocity of the spaceship that is firing to the bullet speeds.

Personally, I have not bothered with such scientific accuracy. I have made my bullets extremely fast projectiles (No tests for collisions as yet!) which seem to work okay using 16-Bit depth as suggested here.