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 / Automatic weapons

Author
Message
NeoHavic
21
Years of Service
User Offline
Joined: 4th Dec 2002
Location:
Posted: 9th Dec 2002 02:52
Does anyone know how to code a machine gun for a game? The gun code that was in the FPS tutorial just wont cut it.
Hilmi2k
21
Years of Service
User Offline
Joined: 29th Nov 2002
Location:
Posted: 9th Dec 2002 10:09
I always wanted to learn how to do that too...

I also was thinking it would be the same thing I require to make multiple instances of the same 3D model. Thats how I could make multiple enemies on the screen...

The Darthster
21
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 9th Dec 2002 17:47
To make machine gun code, you make several bullet models (about 5-10 are needed) and make an array of where each one is, which way it is pointing and how much life it has left. Here's some code which might be useful, it's a space flight sim developed for someone else, primarily for the space controls but it features a machine gun on the middle mouse button:

Skid
21
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: United Kingdom
Posted: 9th Dec 2002 18:31
You don't need the arrays to hold all that data, thats what the object position x() command is for, plus you don't need it to move the bullet. Right off the top of my head you need an array for life, depending on how fast you want it to fire you should use a varible to space the bullets out. You also need lots of bullets, depending on the speed and life (this is so you the game doesn't crash if it runs out of bullets.
After you got all that you need bits of code to fire the bullets, another small bit to move them and one more to remove them. When fireing them set them to the position and oritation of the object there fireing from, you may need to move them a bit to make it look right.



ok thats from the top of my head, heres a key:
*1* = The object thats fireing the bullet
*2* = Speed of the bullet
*3* = Time between bullets

hope that helps

Skid

Login to post a reply

Server time is: 2024-04-27 04:41:24
Your offset time is: 2024-04-27 04:41:24