Game Development Community

Weapon recoil

by Zodiack_Killer · in Torque Game Engine · 04/02/2004 (9:07 pm) · 6 replies

Ok, probably showing my incompetence here...but does anyone know how to implement a weapon recoil like the one in the laserbeam tutorial (Laser Beam)? The only thing I can find on it is a few forum threads, but those are pretty outdated and never really recieved an answer. anyways, thanks in advance for any help you may be able to offer.

#1
04/03/2004 (7:02 pm)
The weapon recoil is an animation for the player object. It simply makes the players' arm (and possibly torso) react to the weapon. It is activated by way of the fire states for the weapon image. You activate it by adding to the "onfire" state of the image with the following:

stateRecoil[3] = LightRecoil;

Where 3 is the appropriate number for your "onFire" state. Of course you must also have a recoil animation for your player model that properly insterted into the TSShapeConstructor (the player from the demo has this animation, so if you are using that model you can simply plug in the line above into the appropriate spot)
#2
04/03/2004 (9:06 pm)
I understand that part, what I haven't been able to do is make the actual weapon react when it's fired. When I ran the script in the tutorial I listed above (the laser beam one) the weapon that I used (one of my own that I know doesn't have a recoil anim) noticably bounced up when it was fired. I'd like to make all of my weapons do this but don't know how. Anyways, thanks for your response, but now that I've hopefully clarified a little better, does anyone have any ideas?
#3
04/04/2004 (4:25 am)
Its not the weapon that react ,its an animation on the player
sequence24 = "./player_recoilde.dsq light_recoil";
If you dont have the light_recoil its not working.

and there is 3 of them
// Recoil animations
recoilSequence[0] = shape->findSequence("light_recoil");
recoilSequence[1] = shape->findSequence("medium_recoil");
recoilSequence[2] = shape->findSequence("heavy_recoil");

and one off the states must be
stateRecoil[3]=LightRecoil;
stateRecoil[3]=mediumRecoil;
stateRecoil[3]=HeavyRecoil;
stateRecoil[3]=NoRecoil;

So you missed something in the scripts on the other weapons.
#4
04/04/2004 (9:13 pm)
Ok...not to sound argumentative or anything (cause I'll probably end up just getting it shoved back into my newbie face anyways) but I don't think I'm clarifying what I'm looking for very well...so here we go again. I already have the LightRecoil implemented into my weapons, and all that they do is cause the weapon/player arm/player body to move a little bit (using the demo anims). What I want is what happens to the weapons in the laser beam tutorial (although I'm beginning to think that the effect is just a fluke I'm experiencing on my computer). Basically, the weapons not only perform the LightRecoil action, but they also noticably move upward and then back into the original position...much like the recoil action in Counterstrike or Halflife. This is what I want. Anyways, I hope that clarifies. I know it isn't just the LightRecoil action though because the demo crossbow uses that and that's not what I want. let me know if anyone can help. I apolagize for not clarifying well enough in the beginning....or the middle...
#5
04/04/2004 (9:54 pm)
Alright...everyone remember that whole probably going to be shoved back into my face comment...happened a little faster than I expected. As it turns out the reason it wasn't working right for me is because I had the eyeoffset set...which causes the gun to remain static. So now I just need to make sure that I set the regular offset as opposed to the eyeoffset. anyways, Thanks for everyone's help, and I apolagize for any wasted time.
#6
03/28/2005 (6:48 am)
Hi,

I'm also trying to create a working LightRecoil blend animation but haven't had much success with it.

I've created the .dsq blend animation and placed the stateRecoil[3} = LightRecoil code into the weapon's .cs file but I still have no visible recoil when I fire.

Billy...what did you mean by recoilSequence[0] = shape -> findSequence("light_recoil")? I couldn't find any resources which mentioned this.

Zodiack_Killer....how did you set the regular offset and deactivate the eyeoffset?

Am I missing something? This seems like it should be easy.

cheers,
k