I am trying to create a first person shooter(very basic) and I am having trouble creating a function to move a bullet. If anyone knows where I can get some info on this I would appreciate it.
What are you using for a bullet? A pixel, a quad, or what?
Move it how? In 2D or 3D?
Do you have collision detection?
It is better to fully explain what you need, and you might want to start a thread in another forum for games, since this is mainly for openGL, and I don’t think you will get many responses.
You should have a direction of the bullet (a vector) or just need to calculate it with weapon & target.
Then use that vector for the traiectory.
For better effect use some more vectors for gravity, wind and so on.
Pseudo code :
DirectionVector += GravityForceVector;
Bullet.Position += DirectionVector;
rIO is quite correct in that bullets can be modeled correctly in games however I feel you should decide what sort of game you are going to be using this bullet in.
In FPS like quake3 the guns that fire bullets (as opposed to rockets etc) move infinitly fast. When you fire, they inpact with what ever they are going to hit ritgh away. Damage is based on how long the bullets are hitting the object. This is because things like the chain gun fire A LOT of bullets in a very short space of time. Running collision detection on each one would be slow.
Things like Delta Force however dont fire as many round in the same time frame (and need to be more accruatly modeled anyway.)
You could cheat internally a bit. When you fire a gun like the chain gun, constuct a spline that goes from the gun to its end point. The end point can be totally accurate in its modeling. Have it leave behind it points that the curve must pass though and there you go, anything intersectiond this curve should take damage.
Right now I am just trying to figure out the math for the bullet position and the timestep to move the bullet. Currently I am using a small quad (about .5x.5). I have collision detection and am in 3D. The game I am using it in is just a very simple target practice game, single fire bullets.
I always thought this bullet problem is just a ray-triangle intersection problem in the lowest level. Or a ray-bbox or, or…
My year’s math test is a work about interpolation with splines! That is cool!