Advertisement

projectile programing

Started by February 23, 2001 01:15 PM
6 comments, last by spot 23 years, 11 months ago
I am trying to make a very simple first person shooter, I have everything except the code for the bullet. I have a bullet that follows the player''s crosshair. Help would be greatly appreciated.
Could you elaborate a little? You say you have everything except the code for the bullet, yet you say you have a bullet that follows the players crosshair... what exactly is the problem? what do you mean it follows the crosshair?

Insomnia
Insomnia
Advertisement
Let me take a stab at this:

By following the crosshair, that's how you update your bullet. Its target is set to your crosshair.

What you need to do is create a little struct for your bullet, containing it's position (x,y,x) and its direction & velocity - you could also include graphic type & animation frame in here.

Then you create a list of these bullets, and each frame cycle through the list until you're done, updating the position in accordance to each bullet's direction and velocity.

Is that what you're after?



"NPCs will be inherited from the basic Entity class. They will be fully independent, and carry out their own lives oblivious to the world around them ... that is, until you set them on fire ..." -- Merrick

"It is far easier for a camel to pass through the eye of a needle if it first passes through a blender" -- Damocles


Edited by - morfe on February 23, 2001 3:59:26 PM
"NPCs will be inherited from the basic Entity class. They will be fully independent, and carry out their own lives oblivious to the world around them ... that is, until you set them on fire ..." -- Merrick
I don''t see the point in showing a bullet animation or even having a model of a bullet, since you cannot see one fire past you in real life with the naked eye.

My advice is, like morfe said, create a struct, but have it contain the X,Y coordinates of your crosshair, and the Z will be definate (since it''s going foward). Then create an imaginary line from your player that keep going until it hits whatever its pointing at. If the line intersects with another player model, have it affect it with damage.

well it might not be a bullet, it could be a rocket, some sort of magical blast or pretty much anything you can think of. Though for standard bullets, yeah just apply the damage directly.
maybe he is asking how to figure out what the bullet hit?
Advertisement
Let me clarify, I have a bullet with (x,y,z) cords that moves foward and stays in the same space on the screen relative to the crosshair while everything else is translated around it. I am makeing the bullet visible so I can see where it goes, this may change later. For right now I am just trying to get one bullet to work, later I will add more.
And sorry about the spelling mistakes in my last post. I saw one and I am sure there are more.

Spot

This topic is closed to new replies.

Advertisement