Page 1 of 1

Dual Guns

Posted: Thu Jun 22, 2006 4:51 pm
by MakerOfGames
Starting this topic so that the off topic section of the media package thread doesnt devour Microman171's need for help.

@ Juutis
How did you attach the dual guns to the player?

Now my plan to do dual guns:
I plan to have a scripted player composed offour main parts(or six if you count the guns).
The player has their torso and legs in one animated section. Then they have two seperate animated arms and a seperate head. The head is seperate for two reasons, one is to have it look down the guns when firing up or down and two it enables an easy way for head shot detection. The arms will spawn at the proper height and rotation as the player via the way I save the models in my 3D modeling application. Then once spawned they will attach themselves to the player and match its z axis rotation. The arms axis will be off set so that it is in the middle of the player so the arms ar always right in front of the player. This will keep the arms exactly where they need to be. Now I dont know how but moving the mouse up will rotate the arms to look up along with the camera and head. The opposite for moving the mouse down. Now the inventory system I havent devised yet, but whatever gun(s) is(are) in your hand(s) will propbably need to have an active true or false state along with a player owner id. This will enable them to respond to the click event and thus fire. If you have the gun in your hand then it is active. (Now gun script)If active and keypress = mouse click then fire(meaning do all events nessicary to create a projectile and launch it. Code to deplete ammo also goes here) I would have each gun keep track of its own stats so that way you can pick up others(enemies) weapons and have whatever ammo that they had left.

That is how I plan to impliment dual guns.

About my weapon inventory:
I dont know how many weapons I want a player to carry at once and that will define how my inventory will work. I will most likely go with a weight and size inventory system. This will let you carry a certain number of weapons based on its weight an size. For example you could carry many pistols at once like 5. Or carry 2 pistols and 2 small sub machine guns. Or one shotgun, and 2 or 3 pistols etc... I dont know if grenades would have there own slots or if they should take up the main inventory.

Post your thoughts.

Posted: Fri Jun 23, 2006 4:52 am
by jonas
Sounds like it might work.

Posted: Fri Jun 23, 2006 9:01 am
by Juutis
Yeah, if you want those guns to work in third person, scripted player is the only choice. Your plan sounds good, indeed.

I made my guns a while back and I decided not to use them, so I don't remember exactly. They worked only in first person (that makes it a lot easier). They were just two pawns which move to player's position each frame and turn up and down with the camera.

Posted: Fri Jun 23, 2006 9:44 am
by Juutis
Oh, another thing...

I guess you want to have inaccuracy in your weapons.

The script command SetTargetPoint() would be handy if there only was some way to get sin, cos, and tan functions to the scripting. I'm using this for my pawns' inaccuracy (they don't need those sin, cos and tan). You could set the target point somewhere ahead of your player with a little random variation and make the weapon pawns shoot at that point.

Another way to do this (and how I do it for my player) is to have a non-rendered pawn somewhere near the player and make it align the player yaw and camera pitch plus a bit random rotation. Then attach firepoint entitys to that pawn and activate them with a trigger when a weapon is fired.

I hope I helped you even a bit but if you already knew this or have a better solution, I guess that at least some people are struggling with inaccuracy and this may get them going. :D

Posted: Fri Jun 23, 2006 5:59 pm
by MakerOfGames
:!: :!: INACCURACY :!: :!:
I ALMOST FORGOT!!!!!
Thank you for the reminder. The system for inaccuracy that I thought up in the past is to to have a variable that modifies how the players arms rotate. Say you have a sub machine gun in your right hand, when you fire, you activate an event that looks at the SMG's recoil/inaccuracy attribute. Based on that number it will rotate the player arms left right up and down and if possible use a random number to decide which direction to move to next. This would create a nice random inaccuracy effect so that the hard core gamers that look for those patterns of inaccuracy cant find one and thus be able to get an accuracte head shot after emptying half an SMG clip and havent stopped firing yet.

This makes me realize that I will have to make the arms axis at the shoulder joint, otherwise the arms would not rotate properly when firing.
Image
I hope this wonderful text img explains what I mean. (I tried to do it in the post but code and regular posting messed up my picture so I went into paint to make this quick)The important thing is note how the right arm is rotated back past the players back.

Scracth the arms axis I mentioned in my previous post. The arms will be seperate from eachother and the player. Their axis will be in the shoulder joint to get proper rotation. Now to get the arms to rotate properly with the player I guess It will just be spawn and attach to shoulder joint bone. That way the arms will always be in the right spot. And of course the arms will match the players z axis. That seems like it covers everything right? Let me know if there area any flaws!

Posted: Fri Jun 23, 2006 6:18 pm
by Juutis
Yeah, it would probably work. The only problems I can think of are these:

1) It might look ugly when those arms are shaking randomly. On the other hand, it might look pretty cool too. :)

2) You'll probably have some problems with weapons that require two hands. It's going to be hard to make the seperate hand pawns to "work together", to have the both hands in the correct place.

Posted: Fri Jun 23, 2006 6:39 pm
by MakerOfGames
Juutis wrote:Yeah, it would probably work. The only problems I can think of are these:

1) It might look ugly when those arms are shaking randomly. On the other hand, it might look pretty cool too. :)

2) You'll probably have some problems with weapons that require two hands. It's going to be hard to make the seperate hand pawns to "work together", to have the both hands in the correct place.
In response to number 1.
Very good point! Maybe I'll make it small arm rotations and add a camera shake for the effect if the arms look weird! :P

Inresponse to number 2.
That will be a challenge. I havent given that much thought yet. *thinking....

I will have to give that some serious thought and post back!

Posted: Thu Jul 06, 2006 4:45 am
by steven8
This sounds really cool and very complicated. Any chance of seeing some snippets of the script? I confess that I am not much of a scripter. Most of my work has been slight modifications of exisitng scripts. I am going to have to spend more time learning this. Since Archon is back with us, he will be the perfect one to help out!!

Posted: Thu Jul 06, 2006 2:05 pm
by shadow
Must have missed this thread earlier.

The easiest way to get inacuracy is just to use controlled random numbers.

This is what I use and it works really well. It is for my rocket firing pawns and is called every shot just befor they fire.

SetTargetPoint( random(-60,60), random(20,80), 400);

// so (-60,60), is left rt
// and (20,80), is up dn
// and the 400 is the point distnce away from the pawn

Looks really cool seeing rockets come zipping by your head, then have five pawns all doing that is awsome.

Posted: Thu Jul 06, 2006 2:48 pm
by MakerOfGames
Well, unfortunantly no script has been started yet. Everything is in psuedo code in my head. I think I figured out a good way for inaccuarcy. The gun is attached to the arms so I will make a few fire animations for the arms. Then when the fire event is started it will chose one of the animations randomly and continue changing randomly until the user stops fireing. This makes single hand and double handed weapons have convincing inaccuracy.

I am not total sure with what you mean Shadow. You script sounds like good but does the gun show any recoil or movement that visually shows inaccuray?

Posted: Thu Jul 06, 2006 4:43 pm
by shadow
Recoil is a great effect but is part of the fire animation.

Realistically you don't need much gun movement that shows inaccuracy, or none at all since the pawn will be facing close to you straight on when he fires.
The amount of deviation for in-accuracy is usually only a few degrees.

With the pawn further away you're not likely going to notice the few degrees of inaccuracy anyways.
If the pawn is close to you (point blank) he really can't miss (so in-accuracy isn't necessary) and may swing the gun butt or kick you instead of firing.

I guess its really personal choice and if the time invested is really worth it to you.

Edit - Sorry just realised your talking about the scripted player not a scripted pawn which I was refering to.

Posted: Thu Jul 06, 2006 11:29 pm
by miccy2000
I don't know how easy the program is to use, but if you want to have your maximum weapons formula based on weight, you could make it so each weapon weighs a certain amount, and a kind of 'Max Weapon Weight Bar' could be shown on the player HUD. If a player has full weapon weight but wants to pick up a rocket launcher, you could make it so the player drops their weakest weapons (or something else, it could be an option thingy in the pause menu) and the rocket launcher replaces it.

Tell us more about the game, it sounds like the next Halo. Well maybe not, but it still sounds cool.

Posted: Fri Jul 07, 2006 3:01 am
by steven8
I like the weight idea, miccy. It adds a bit of realism to a game. You could add an attribute called 'weight, and modify it each time a weapon is picked up. Different amount for each weapon, of course, but when it reached a certain amount, one weapon would be dropped from inventory in favor of it. The players would have to watch what weapons they picked up, so as not to lose a favored weapon for a lesser one.

Very cool idea!

Posted: Mon Jul 10, 2006 3:54 pm
by MakerOfGames
I really like that weight idea!!! Thanks, I think I will impliment that exact system with a good interface to macth my HUD I'm woking on. Oh, I'm posting here because I needed a question answered about my HUD and I thought I would post in this section becase its up there on my RF to do list. Also, shadow, I see what you mean by little recoil(a few degrees) changes the path of a projectile. I think I might use your pawn innaccuracy but apply it to the scripted player. It should work... The only thing is to get this system to work it will take a lot of time. Then to make it work with my HUD... that will only take more time. Ok, back to implimenting my own HUD.
I should be back to posting regularly on Fri.

Thanks for the compliment Miccy2000 :D ! I would be very happy if I could make a game anywhere close to the giants in the industry.

I will tell everyone more about my game in the near future. I want to finish the general story before I let it be known to the world. I am doing this because I have already trashed 2 other story ideas I have worked on in the last 2 years.