Chaingun....
by Lane Anderson · in Torque Game Engine · 03/03/2005 (4:31 pm) · 16 replies
How would I go about making one? I was thinking I would be able to just modify the crossbow datablock to fire faster, and make a new model, but the crossbow doesnt seem to be able to spray bullets like a chaingun should be able to :)(it waits until the one you have shot has inpacted before firing the next) . Could someone get me started on the right path to getting a weapon that can fire LOTS of bullets very fast, and animate accordingly?
Thanks,
Lane
Thanks,
Lane
About the author
#2
09/26/2006 (1:48 pm)
I'm interested in the same thing, i saw an old resource to make a chaingun but the animations look sub-par, I have a nice chaingun made with nice smooth animations, but modifying the crossbow script isnt goign to cut it, I think the answer will lie in the sequence timeout values, as well as in the length of the animations, I tried to modify the onfire function but it just fires a bunch of shots nearly simultaniously, not sequentially as I would like them to do
#3
09/26/2006 (1:53 pm)
Lower the timeout value?
#4
1) Look at how a chain gun functions: spins up, sprays a rediculous amount of bullets, and then spins down.
Sounds like three firing states to me.
From a FPS design perspective, you have 7 states: raise weapon, idle, spin-up, fire, spin-down, reload, dry and fire
2) When in doubt, try to find a previous example such as the above listed shotgun script.
Or, if you own Doom 3, open up the chaingun script and see how they handle it.
I had to write a full weapon system from scratch using C++ and Lua for my last game
I drew inspiration from Doom 3's script and Torque Script to get it done.
09/26/2006 (1:58 pm)
I have two suggestions...1) Look at how a chain gun functions: spins up, sprays a rediculous amount of bullets, and then spins down.
Sounds like three firing states to me.
From a FPS design perspective, you have 7 states: raise weapon, idle, spin-up, fire, spin-down, reload, dry and fire
2) When in doubt, try to find a previous example such as the above listed shotgun script.
Or, if you own Doom 3, open up the chaingun script and see how they handle it.
I had to write a full weapon system from scratch using C++ and Lua for my last game
I drew inspiration from Doom 3's script and Torque Script to get it done.
#5
09/26/2006 (2:32 pm)
I think there is also some built in code for handling chaingun type animation left over from Tribes in the ShapeImage class. Though I'd have no idea to use it, if you looked up the old T2 scripts they might have some reference.
#6
09/26/2006 (2:45 pm)
Aye, spinThreads. Basically you need one animation that is called something special (cant remember what, but if you get Tribes II and check their .dts's with ShowTool, it should give you an idea) which contains the full 360 degrees of rotation.
#7
Like S. Lundmark stated above..... Need to export a "Spin" sequence ( should be a 360 spin) with all the others you need .. fire, reload, no ammo
Then use...
stateSpinThread[] Play this spin animation (blended).
"Ignore"
"Stop"
"SpinUp"
"SpinDown"
"FullSpeed"
You call normal states... statethread[] statename
then at anytime u can call on the spin animation from the stateSpinThread FullSpeed
This while spindown is active run StateSpinThread.. I got that far.. and have a problem.
1 blank frame.. in the export.. how can I remove this. It keeps spinning but a pulse in the animation after a complete cycle of the spin.
Is there a way to avoid adding 1 frame to the end of a export
09/26/2006 (3:30 pm)
HI, I also have been plugin at this..... Like S. Lundmark stated above..... Need to export a "Spin" sequence ( should be a 360 spin) with all the others you need .. fire, reload, no ammo
Then use...
stateSpinThread[] Play this spin animation (blended).
"Ignore"
"Stop"
"SpinUp"
"SpinDown"
"FullSpeed"
You call normal states... statethread[] statename
then at anytime u can call on the spin animation from the stateSpinThread FullSpeed
This while spindown is active run StateSpinThread.. I got that far.. and have a problem.
1 blank frame.. in the export.. how can I remove this. It keeps spinning but a pulse in the animation after a complete cycle of the spin.
Is there a way to avoid adding 1 frame to the end of a export
#8
09/26/2006 (5:49 pm)
Maybe just spin one barrel at a time?
#9
09/26/2006 (6:19 pm)
Freeze, there is a way to avoid doing that, but I cant remember it off the top of my head. Just keep tweaking until you get it right, then save that file somewhere veeeeery safe so you can get it later :)
#10
1) Create a 360 degree spin animation for the minigun barrel. Name it spin.
2) If you want a muzzle flash, create a separate animation named fire_vis with your muzzle flash visibility animation. Then set stateSequenceRandomFlash to true in your firing state.
3) Use a looping sound for the fire sound.
Set up your state system as follows:
Voila, a working minigun.
I haven't had any problems doing it this way. Spin animation plays correctly on my model.
09/26/2006 (11:07 pm)
To get the basics of a minigun working:1) Create a 360 degree spin animation for the minigun barrel. Name it spin.
2) If you want a muzzle flash, create a separate animation named fire_vis with your muzzle flash visibility animation. Then set stateSequenceRandomFlash to true in your firing state.
3) Use a looping sound for the fire sound.
Set up your state system as follows:
//-------------------------------------- stateName[0] = "Activate"; stateSequence[0] = "Activate"; stateSound[0] = VulcanSwitchSound; stateAllowImageChange[0] = false; // stateTimeoutValue[0] = 0.5; stateTransitionOnTimeout[0] = "Ready"; stateTransitionOnNoAmmo[0] = "NoAmmo"; //-------------------------------------- stateName[1] = "Ready"; stateSpinThread[1] = Stop; // stateTransitionOnTriggerDown[1] = "Spinup"; stateTransitionOnNoAmmo[1] = "NoAmmo"; //-------------------------------------- stateName[2] = "NoAmmo"; stateTransitionOnAmmo[2] = "Ready"; stateSpinThread[2] = Stop; stateTransitionOnTriggerDown[2] = "DryFire"; //-------------------------------------- stateName[3] = "Spinup"; stateSpinThread[3] = SpinUp; stateSound[3] = VulcanSpinupSound; // stateTimeoutValue[3] = 0.5; stateWaitForTimeout[3] = false; stateTransitionOnTimeout[3] = "Fire"; stateTransitionOnTriggerUp[3] = "Spindown"; //-------------------------------------- stateName[4] = "Fire"; stateSequence[4] = "Fire"; stateSequenceRandomFlash[4] = true; stateSpinThread[4] = FullSpeed; stateSound[4] = VulcanFireSound; stateRecoil[4] = LightRecoil; stateAllowImageChange[4] = false; stateScript[4] = "onFire"; stateFire[4] = true; stateEjectShell[4] = true; // stateTimeoutValue[4] = 0.065; stateTransitionOnTimeout[4] = "Fire"; stateTransitionOnTriggerUp[4] = "Spindown"; stateTransitionOnNoAmmo[4] = "EmptySpindown"; //-------------------------------------- stateName[5] = "Spindown"; stateSound[5] = VulcanSpinDownSound; stateSpinThread[5] = SpinDown; // stateTimeoutValue[5] = 1.0; stateWaitForTimeout[5] = true; stateTransitionOnTimeout[5] = "Ready"; stateTransitionOnTriggerDown[5] = "Spinup"; //-------------------------------------- stateName[6] = "EmptySpindown"; stateSound[6] = VulcanSpinDownSound; stateSpinThread[6] = SpinDown; // stateTimeoutValue[6] = 0.5; stateTransitionOnTimeout[6] = "NoAmmo"; //-------------------------------------- stateName[7] = "DryFire"; stateSound[7] = VulcanDryFireSound; stateTimeoutValue[7] = 0.5; stateTransitionOnTimeout[7] = "NoAmmo"; };
Voila, a working minigun.
I haven't had any problems doing it this way. Spin animation plays correctly on my model.
#11
09/27/2006 (3:11 pm)
*thank you*
#12
Grrrrr
Results from a few hours of max showtool and tge.
In my trail and error , I had better result.... making the animated export turn only one barrel. exported with 480fps in 4clicks 2 keys in max.
So if you have a 10 barrel chaingun.. making the "Spin" sequence rotate only 36 degress.
This setup looks good for me . It will spin 360 degress no matter how much of a spin you export. 2-360 .
They all spin a full 360. The timming and effects will change and need adjusted on every giving model. I wouldn't export a 360 spin, Unless your Not going to use the stateSpinThread kinda defeats the purpose.
When i export with a 360 spin it spins yea.. but the projectile timming of the barrel and flash of fire_vis effects are not insync. To be honest it just looks like a good try. hehe
The chaingun is ment to fire very fast and spin. The stateSpinThread and the stateThread "fire" Do all the work for the most part. Try your spin sequence set to the amount of barrels you have divided by 360.
All the other animations like the fire_vis Flash and sound of fireing will be timed perfect to the projectile exit.
Let the stateSpinThread do the spinning for you. If you export a 360 spin why not just loop the animation when fireing.
Thanks for the help guys... and I hope Lane got his working too. Thanks for the thread it was very helpful.
09/27/2006 (3:31 pm)
Checking back in... Still can't get max to export any damn thing with out adding a blank frame to the end. Grrrrr
Results from a few hours of max showtool and tge.
In my trail and error , I had better result.... making the animated export turn only one barrel. exported with 480fps in 4clicks 2 keys in max.
So if you have a 10 barrel chaingun.. making the "Spin" sequence rotate only 36 degress.
This setup looks good for me . It will spin 360 degress no matter how much of a spin you export. 2-360 .
They all spin a full 360. The timming and effects will change and need adjusted on every giving model. I wouldn't export a 360 spin, Unless your Not going to use the stateSpinThread kinda defeats the purpose.
When i export with a 360 spin it spins yea.. but the projectile timming of the barrel and flash of fire_vis effects are not insync. To be honest it just looks like a good try. hehe
The chaingun is ment to fire very fast and spin. The stateSpinThread and the stateThread "fire" Do all the work for the most part. Try your spin sequence set to the amount of barrels you have divided by 360.
All the other animations like the fire_vis Flash and sound of fireing will be timed perfect to the projectile exit.
Let the stateSpinThread do the spinning for you. If you export a 360 spin why not just loop the animation when fireing.
Thanks for the help guys... and I hope Lane got his working too. Thanks for the thread it was very helpful.
#13
09/27/2006 (5:53 pm)
Tim - can you please explain the muzzle flash animation setup? I havnt seen that at all yet.
#14
Instead of using a particle emitter for a muzzle flash, you can create one within your model. It's kind of like a billboard effect.
So imagine your weapon model in your modeling application (I use Max)
- You create two flat plains in the form of a cross.
- Place them at the end of the barrel (where you want the flash to appear)
- Texture them with an alpha channeled fire / flame texture
- In your weapons fire animation, you use a visibility animation to get them to appear and disappear
- Now, when you fire your gun, you have a flash that flickers at the end of it (AKA muzzle flash)
Miniguns have to be set up a little differently as with miniguns you need to play two animations at once. I.e. the spin and fire flash. Torque doesn't support more than one animation at a time for weapons, with the exception of miniguns. Because torque uses the one spin animation to work out spin up, full spin, and spin down, that's why you need to set the random flash animation to true in script within the fire state. So the muzzle flash only plays when firing, at full spin, and at no other time (such as spinning up and down).
I'm a little tired at the moment so I'm probably not making as much sense as I could be. Here are some screens that might explain it better.
So, here's my desert eagle pistol with a muzzle flash I quickly made in show tool:

Now, here's what the flash looks like un-textured.

The flash will look like it's 3d from most angles.
Clear as mud?
09/27/2006 (6:42 pm)
Hi Jeff,Instead of using a particle emitter for a muzzle flash, you can create one within your model. It's kind of like a billboard effect.
So imagine your weapon model in your modeling application (I use Max)
- You create two flat plains in the form of a cross.
- Place them at the end of the barrel (where you want the flash to appear)
- Texture them with an alpha channeled fire / flame texture
- In your weapons fire animation, you use a visibility animation to get them to appear and disappear
- Now, when you fire your gun, you have a flash that flickers at the end of it (AKA muzzle flash)
Miniguns have to be set up a little differently as with miniguns you need to play two animations at once. I.e. the spin and fire flash. Torque doesn't support more than one animation at a time for weapons, with the exception of miniguns. Because torque uses the one spin animation to work out spin up, full spin, and spin down, that's why you need to set the random flash animation to true in script within the fire state. So the muzzle flash only plays when firing, at full spin, and at no other time (such as spinning up and down).
I'm a little tired at the moment so I'm probably not making as much sense as I could be. Here are some screens that might explain it better.
So, here's my desert eagle pistol with a muzzle flash I quickly made in show tool:

Now, here's what the flash looks like un-textured.

The flash will look like it's 3d from most angles.
Clear as mud?
#15
09/27/2006 (8:20 pm)
Mostly, i think you've spelled it all out except for how the visibility animation should go... clear visable clear, or just clear to visable.... theres practically been a complete chaingun tutorial worked out in this thread today! :)
#16
@Tim: looks somewhat like the leading edge of the billboard has a pixel line, or smear; I can see the edge?! I've seen that with some textures for foliage replicators in the past.
09/28/2006 (6:18 am)
Clear-Visible-Clear. Should produce a nice smoothe 'flash'. Depends on how you want it to look; produce a few types, ;)....@Tim: looks somewhat like the leading edge of the billboard has a pixel line, or smear; I can see the edge?! I've seen that with some textures for foliage replicators in the past.
Torque 3D Owner Pat AfterMoon
Realistic shotgun script with multiple projectiles and impulse blast :
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6237
Free Game Ready Shot Gun Model :
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6282