3
$\begingroup$

I have a complex question, so bear with me. I have 3 primaries, 3 secondaries, and 3 melees. I want a system where you can swap between primary, secondary, and melee when each of which can have a different weapon. I have a very simple .blend to get you started; all it is is basically a camera, and 3 types of primary, secondary, and melee; they all have animations and have different colors to help you. Here is a list of things I want with this system:

  • "Weapon Active" property; each weapon will have its own ("Smg1Active," "Smg2 Active," ...), and this will be used in such a way, for example, when a certain weapon is active, this property will be set to 1, and will allow me to make the character move faster and slower based on which item is active.
  • Live weapon swap: If you are selecting the primary, and suddenly the primary is smg2 instead of smg1, I want the start animation for smg2 to occur; smg2 to be active, and smg1 to be gone.
  • Invisibility: This is fairly simple, but when an item is not active I want it to be invisible, as I do not want other cameras to see guns floating.
  • Properties: I want the following properties: "Primary" (Set to 1 when primary is active); "Secondary" (Same but for secondary); "Melee" (Same but for melee); "PrimaryID" (Each weapon has its own id, as in smg1's id is 1, smg2's id is 2, and so forth); "SecondaryID" (Same but for secondary); "MeleeID" (Same but for melee).
  • Everything clean: Try to keep everything nice, and not scattered everywhere.

I know that is fairly hard, but I tried so many things but always failed. Try to explain your work very neatly. I want to always be able to go back, and edit it with ease. Thank you for your time!

$\endgroup$
  • $\begingroup$ Do you know code enough to successfuly do this? I am devoloping a fps game [In unity , not blender] , and the way i switch weapons is to disable every gun , Except the one you want active , And for each gun there is a class . When you switch to that gun , that guns class is active , and when that guns class is active and you press buttons then it will do the programmed commands for them. thats the logic of mine $\endgroup$ – Knuckles209cp Jan 17 '15 at 3:48
  • $\begingroup$ Hm. I do it a similar way all in logic bricks though. $\endgroup$ – blackhole Jan 17 '15 at 6:00
  • $\begingroup$ I wish i could help but i only know how to do this inside unity sorry. $\endgroup$ – Knuckles209cp Jan 17 '15 at 6:01
  • $\begingroup$ @BlenderDev At some point you just need to learn python. $\endgroup$ – GiantCowFilms Jan 19 '15 at 16:30
  • 1
    $\begingroup$ @BlenderDev Python is a much simpler language than Lua or Java, I simply learned Python from reading the docs on python.org, the starting tutorial is actually quite good as docs go. $\endgroup$ – PGmath Jan 19 '15 at 23:23
1
$\begingroup$

That's quite easy to do. You don't even need to use Python, you can do this with logic bricks, properties and messages.

I've got an example .blend here: http://www.pasteall.org/blend/33896

Press P to start. Change weapons with 1, 2 or 3 keyboard keys. Notice how the wepon is lowered, then changes, and then plays a setup animation. Right now all the weapons play the same animation, but you could make several different ones if you like and link those up.

I've done in a slightly different way than you requested. Instead of adding/removing weapon objects, I've used Replace Mesh to change the weapon, and a active weapon int property. I've found this to work better, and you don't need to worry about having the new weapon follow the character around this way. You can check for this int and change behaviours for the different weapons (to add different bullets or whatever).

I don't quite understand you requests about a 'Primary' property, but you can add that yourself, no problem.

For actual shooting, just add a Shoot action with some weapon movement and an empty in front of the weapon to emit bullets. These things can be set up to listen to the active weapon and change their behavior.

Hope this works out for you. These things are not really that hard once you get a hang of Properties and Messages. Cheers.

$\endgroup$
  • $\begingroup$ One issue. I have multiple weapons for primary, secondary, and melee. What if you swap to primary and there are multiple types? How do I achieve this? $\endgroup$ – blackhole Jan 20 '15 at 22:44
  • $\begingroup$ @BlenderDev Switching between different types is easy... You just say I'm switching between 9 weapons... and build it that way. $\endgroup$ – GiantCowFilms Jan 21 '15 at 4:11
  • $\begingroup$ I am not saying 9 weapon slots, im saying 3 weapons PER slot. $\endgroup$ – blackhole Jan 22 '15 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.