Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Question about shooting in an FPS game

Author
Message
FPS Mastermind
19
Years of Service
User Offline
Joined: 14th Nov 2005
Location:
Posted: 14th Nov 2005 16:37
Hello everyone! Well, this is my first post on the forums. I was wondering how to make an enemy shoot in an FPS game if there is more than one bullet in the game. Also, how would you do this for the player too. I have been reading some of the tutorials from the manual, and they are really no help. I would like some better documentation next time. So, what should I do? Should I just use an array that stores the bullets in it? Could someone just give me a mini tutorial or point me to a good tutorial on the subject matter?

Thanks in advance.

The Big DarkBasicPro Newbie.

Hey, I am a total noob to DBP, so if you would be kind enough to just help me along.
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 15th Nov 2005 02:17
Some effort in using the search button would help;

http://www.ruccus.net/Tutorial.htm

A tutorial on creating FPSs, its incomplete but has instructions on shooting rapid bullets. Most modern guns shoot so fast that you cant see the bullets, so instead of creating objects and moving them you can just use the intersect object command to determine if theres an object infront of the user, if so then damage the enemy. Read the tutorial for more info.

As for moving slower bullets like rocket launchers or old fashioned guns, I'll be adding that to the tutorial in due time, I dont have time to explain the theory behind calculating in the velocities, gravity on the bullets, amount of bullets to create, factors of collision and so on, but I hope the intersect object shooting will work for now.

Once again, use the search button and you'll find your answer. If you search it, they will come.

FPS Mastermind
19
Years of Service
User Offline
Joined: 14th Nov 2005
Location:
Posted: 15th Nov 2005 14:52
Okay, thankyou very much. Would this also apply to enemies shooting?

Hey, I am a total noob to DBP, so if you would be kind enough to just help me along.
mr_fan
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: look... behind you.
Posted: 20th Nov 2005 06:07
a tick that I learned, that if you have never done bullets before, just constantly move the bullet object, just keep the bullet moving all the time, like this:

hope this helps, a little, I'm not that good at making bullets, but this is as simple as it gets (not simple coz you don't wana do work, because you r new at it, well, for me that is)
loop

rvb Church: "hey, look, his armor its, red."
rvb Tucker: "well that'l explain how he got past our defences."
rvb Caboose : "Actuley he came through the back."
mr_fan
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: look... behind you.
Posted: 20th Nov 2005 06:08
oops, this is what I meant to do:



rvb Church: "hey, look, his armor its, red."
rvb Tucker: "well that'l explain how he got past our defences."
rvb Caboose : "Actuley he came through the back."
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 20th Nov 2005 15:43
why do people make objects for shooting in an FPS. Unless it is something like a rocket where you see the bullet there is no need to. Just put a limb in front of the character and use intersect object. Do the same thing for enemies even. Although you'll want to put muzzle flashes on the enemies so people can see where they are getting shot from


The old sig is back
FPS Mastermind
19
Years of Service
User Offline
Joined: 14th Nov 2005
Location:
Posted: 20th Nov 2005 16:17
Yes, but how would you do that for enemies, and if it goes through a wall, then what? I want the player to see the bullets. The bullets are not too fast, but the player will have about 5 out at a time tops on one of the big guns. How would you make enemies shoot?

Hey, I am a total noob to DBP, so if you would be kind enough to just help me along. I'm good with FPSC though, just learning DBP now.

devastation
19
Years of Service
User Offline
Joined: 11th Aug 2005
Location:
Posted: 20th Nov 2005 17:00
have a couple extra bullets in the cycle and have one spawn by the enemy and point at you plus or minus random so they dont have perfect acuracy. then move the bullet like normal and check for collision with the player.

verydevastating.com
FPS Mastermind
19
Years of Service
User Offline
Joined: 14th Nov 2005
Location:
Posted: 20th Nov 2005 17:49
Sounds good. Thanks a ton. My game is a doom style game I am making. I can give you some screens of the cutscenes if you would like.

Hey, I am a total noob to DBP, so if you would be kind enough to just help me along. I'm good with FPSC though, just learning DBP now.

mr_fan
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: look... behind you.
Posted: 20th Nov 2005 17:57
cool,

rvb Church: "hey, look, his armor its, red."
rvb Tucker: "well that'l explain how he got past our defences."
rvb Caboose : "Actuley he came through the back."
Peter H
20
Years of Service
User Offline
Joined: 20th Feb 2004
Location: Witness Protection Program
Posted: 21st Nov 2005 15:24
Quote: "Yes, but how would you do that for enemies, and if it goes through a wall, then what? "

the intersect object command would give you the object id of the wall and you would say "hey that's not the player!" and disregard it...

"We make the worst games in the universe..."
Dodic
19
Years of Service
User Offline
Joined: 6th Nov 2005
Location: SNM (Serbia&Montenegro)
Posted: 21st Nov 2005 17:35
you can make it , insead of using command to move object , and then put it back , you could use command to create new objects and move it and after some time delete it .

you only live once , but you die twice
born and death!
Dodic
19
Years of Service
User Offline
Joined: 6th Nov 2005
Location: SNM (Serbia&Montenegro)
Posted: 21st Nov 2005 17:35
p.s. i`m sory i don`t have much time now , but i`l post you the code of what i mean later.

you only live once , but you die twice
born and death!
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 21st Nov 2005 18:16 Edited at: 21st Nov 2005 18:18
You're getting into more of an A.I question than a shooting question. The actual shooting routine is the same for the enemies as it is for the user. Just check for intersection infront of the user and hurt them if the shooter is shooting.

In the case of walls being in the way you simply do another intersection check for all other non-enemy objects, and check if the distance to that intersection is less than the distance to the enemy intersection, if so then dont damage the enemy.

As for adding some brains to the enemy, for some basics just have the enemy constantly turning in one direction until they find an intersection with a user. If the user is the closest intersection to them then stop the enemy from turning and begin the shooting routine for the enemy, possibly add in moving forward at the same time and maybe even setting it's rotation to the user's rotations o the enemy will follow.

This is, ofcourse, very basic, but from the basics you can implement more dynamic routines like A*; path-finding, and other elements.

In theory you want to start very basic, with the enemy just constantly shooting infront of them, then move onto only shooting when the user is infront, then only shooting when the user is closest and infront, then adding in some movement (rotation and possibly some randome forward/backward movement), then more dynamic movement (having the enemy follow the user), then path-finding, and from there who knows, maybe a sense of hearing?

<EDIT> Also, don't forget to make the enemy run out of ammo aswell. A lot of games forget this aspect and end up having the enemy have unlimited ammo.

Goodluck.

FPS Mastermind
19
Years of Service
User Offline
Joined: 14th Nov 2005
Location:
Posted: 21st Nov 2005 22:36
Thanks for the help guys. I will try out some enemy shooting later, but I am trying to put in the player right now.

Hey, I am a total noob to DBP, so if you would be kind enough to just help me along. I'm good with FPSC though, just learning DBP now.

Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 22nd Nov 2005 04:21
Here is another piece of advice. Don't listen to Dodic.



FPS Mastermind
19
Years of Service
User Offline
Joined: 14th Nov 2005
Location:
Posted: 23rd Nov 2005 17:46
Gottcha . So, I have an idea of how I am going to do shooting within the game. I was thinking of having three bullet objects in the world at all times when the person shoots it ups the counter and repositions the bullet and does what it needs to do for shooting. Thanks for the help!

Mastermind

Hey, I am a total noob to DBP, so if you would be kind enough to just help me along. I'm good with FPSC though, just learning DBP now.

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 23rd Nov 2005 18:07
Quote: "three bullet objects "


Why are you still using objects ?! Is this gun firing slow projectiles or fast bullets like modern guns?

FPS Mastermind
19
Years of Service
User Offline
Joined: 14th Nov 2005
Location:
Posted: 23rd Nov 2005 19:34
You will be firing the following types of bullets:

1) Lasers
2) Plasma Rays (Big Red Ball)
3) Rockets
4) Faster bullets
5) Granades

I want this game to be visually appealing so you see the bullet hit the enemy and the enemy becomes bloodstained and falls on the ground with an animation. I do not want there just to be some muzzle that shows up, it is not as rewarding.

Also, the game takes place around the turn of the century to 2100 where they just developed lasers and they are slower moving.

Hey, I am a total noob to DBP, so if you would be kind enough to just help me along. I'm good with FPSC though, just learning DBP now.

BLink
20
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 23rd Nov 2005 20:21
Wow, what luck. I'm actually a totally new guy that's trying to make a similar game in some aspects, a Metroid FPS, and I needed to figure out how to make visible bullets(or plasma rather) as well.

I'll try to use this advice for my own game, I'm so very glad I looked at the board before posting my own topic.

Oh, and is there anything different I should know about this since I'm using DBC?

www.gameroom.com/blinkcomic
Train04
19
Years of Service
User Offline
Joined: 14th Nov 2005
Location:
Posted: 23rd Nov 2005 20:26
hi im also new im having trouble geting a sphere to rotate and go foward i can do it with an ordanary object but when it comes to a cube sphere ect then it wont rotate why or go foward or back.

(=:
BLink
20
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 23rd Nov 2005 22:06
I think that's a bit off topic Train04...

Well, I messed with Smart Guy's code and got it to work a few times in DBC(I accidentally closed the file though), but I'm having trouble with what I've always had trouble with, repeating bullets. I don't mean to sidetrack this topic, but can someone explain to me the best way(possibly with code showing it) how to do repeating bullets? Thanks!

www.gameroom.com/blinkcomic
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 24th Nov 2005 19:52
You can still have the user see lasers flying around without making objects, well atleast without making tonnes.

One idea, that's very basic and there's probably better ones, is to just create a long cylinder the size of the intersection ray, and everytime the user shoots show the cylinder, then just texture the cylinder with a laser colour.

BLink
20
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 24th Nov 2005 21:54
Yeah, but you know how in Metroid the blasts are seperate objects, and how enemies react when they're physically hit by the blasts? That's what I'm aiming for.

www.gameroom.com/blinkcomic
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 24th Nov 2005 22:57
As I said that was one suggestino.

You could create an animation of the laser beam and texture it onto the cylinder, then check if the animation is at the last frame (meaning the laser is at the end of the cylinder) and if the gun is still intersecting with the enemy, if so damage the enemy.

Whatever all Im saying is creating loads of objects flying around at fast speeds checking for collision with them constantly every loop will add a lot of un-needed lag.

BLink
20
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 25th Nov 2005 00:46
Yeah, but I can't exactly have a texture on a cylinder for rockets.

What I really want, really, really want, is to just know how to have multiple objects firing out of a gun, and have more than one of them being out of the gun and visible, at the same time. There can be a delay, like half a second or a second between shots, as to make it not lag, but really, all I care about right now is learning how to make multiple objects come out. It's been a huge problem for me for months, and people always try to get me to do it a different way, but it's important that I actually learn how to do it.

So, if you could just tell me how to make it shoot multiple real, visible objects from the gun, that would really help me far beyond what you think. From what I know so far, I think it's just using For n = 50 to 100 and next n commands, something about using an array to progress through the bullets, but I still really don't understand much if any of it, so I really need help on this.

Pineapple juice, the best drink ever made.
FPS Mastermind
19
Years of Service
User Offline
Joined: 14th Nov 2005
Location:
Posted: 25th Nov 2005 16:15
RUCCUS: He is looking for objects that are like rockets that have a definative shape. And sometimes a shaped object is much more appealing than just an animation.

Hey, I am a total noob to DBP, so if you would be kind enough to just help me along. I'm good with FPSC though, just learning DBP now.

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 25th Nov 2005 16:57
I see that now but before it had sounded like he just wanted lasers, like the effects in starwars.

FPS Mastermind
19
Years of Service
User Offline
Joined: 14th Nov 2005
Location:
Posted: 25th Nov 2005 19:39
Ah, I gotcha. I think I am going to use that in one of the games I am making, but not for this one. This one is supposed to be extremely visually appealing, and I found a way to transfer over to XBox 360.

Hey, I am a total noob to DBP, so if you would be kind enough to just help me along. I'm good with FPSC though, just learning DBP now.

BLink
20
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 26th Nov 2005 03:35
Well then, I guess that's two people in this topic who need to learn how. Anyone willing to show us?

(and good luck with the 360 thing FPSM)

Pineapple juice, the best drink ever made.
FPS Mastermind
19
Years of Service
User Offline
Joined: 14th Nov 2005
Location:
Posted: 26th Nov 2005 20:23
Thanks. All you have to do is use Dark Game SDK and add your own DirectX library to support things that DBSDK does not offer or is not compatible with.

Hey, I am a total noob to DBP, so if you would be kind enough to just help me along. I'm good with FPSC though, just learning DBP now.

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 28th Nov 2005 01:05 Edited at: 28th Nov 2005 01:16
Ill be adding in how to throw projectiles like nades and shoot slow objects like raockets into the FPS tut soon, but just ask Antidote how "soon" soon is and you'll begin to seem less faithful Got some projects due this week so I dont have time to work on it for a few days atleast.

As for theory;

- Position the object to be projected at the coordinate you wish (the gun, the user's head, the user's position, whatever)
- Rotate the projectile to be equal to the projecter's angle (the gun, the user, whatever again)
- Begin moving the object forward at the pace you want

Pretty simple, taking it further;

- To add some weight, define a variable, say, Fall#, as a positive value, then use the POSITION OBJECT command to position the projectile at it's x, it's y plus the Fall value, and it's z, then just decrease the fall value by whatever rate you want each sync. This will at the beginning move the projectile upward for a bit, but then the variable will become positive and will move the projectile downward, it's smooth if you give the rate of decrease of Fall a small value.

Even more so;

- Delete or hide or reposition the bullet object when it collides with anything or is too far away

- Check for collision using whatever method you like, i'd use collision boxe's since it doesn't have to be too acurate, but intersection checks or sphere collision could work too.

- Then just handle the variable appropriately, resetting the Fall value, decreasing Ammo, damaging living objects the projectile collides with, etc.

For explosives...

- If it's a nade you could use a timer then when the timer reaches the required time create a large sphere at the nade position and damage anything touching the sphere

- or -

- If its a rocket do the same without the timer

- Maybe add some forces onto the explosion, like moving the object hit backwards, the speed of movement would depend on the distance to the explosion core.


Hope it helps, like I said I'll be adding it to the tutorial next hopefully since I'm planning on incorperating multiple weapons next (shotgun, rocket launcher, grenade, knife, sniper, smg, pistol)

If you haven't seen the tutorial yet, the link is:
http://www.ruccus.net/Tutorial.htm

From there you'll find the main tutorial, the current code, a screenshot (not recent sorry), a link to the forum that started it all, some notes and soon a compiled .exe for those not with DBP on their computer at the time.

Oh and the tutorial is for DBP.

BLink
20
Years of Service
User Offline
Joined: 1st Jan 2004
Location: Laptop, wherever that is
Posted: 30th Nov 2005 05:47 Edited at: 30th Nov 2005 07:29
Thanks very much Ruccus, but that's really not what I've been trying to figure out. I'm having problems getting multiple bullets/objects coming out of the gun, not at the same time, but still existing outside the gun at the same time(say, shooting three bullets in a row, and having them all out at the same time, like in a machine gun). I don't want to do the single bullet thing that works for missles with the bullets I'm using, I want to be able to have a bunch on screen at the same time. I use DBC btw, and I've check out your tutorials, but they don't help me in that aspect, where I need it most.

EDIT: Nevermind! Oh, nevermind, I finally figured it out.



if Bullet#>20 then Bullet#=10

And that works! Or something like that, that's what I wanted to know about.

Pineapple juice, the best drink ever made.

Login to post a reply

Server time is: 2024-11-27 12:24:08
Your offset time is: 2024-11-27 12:24:08