I really don't remember what comes next...

Okay I’m lost on what comes next… (My mind is not thinking too clearly about this…)

http://www.pasteall.org/blend/13325

So I have set up a Player and two guns (Pistol and a Rifle) both have property’s (named Pistol and Rifle) When your near one of the guns press CTRL and it will disappear… (End Obj) But how to make it show up and shoot in your hands?

And does the guns (The parented to the Player) need to be Invisible?

You can create an empty and put it were you want your gun to be when your character is holding it and then parent that to your character, and then when you press ctrl to pick up the gun you could have a message sensor send a message to the empty to create the gun, then you will have to parent the gun to the empty. I don’t know if you can parent the gun to the empty through the logic bricks or not, but you can do it with python. I’ll try to put together an example blend.

@kevincorrigan: Thanks I’ll look forward to seeing it.

I was going to try to make to make it when you press CTRL near one of them, it would remove the gun on the ground then using an Empty have it AddObject the pistol/rifle (I just think that would fail…And then of course the guns empty and removing both to switch the weapons…So Idk my way would work…)

Yep tested my idea out…FAILED horribly…Not even going to post it here…Its just a SUPER LAGGER GUN!!! (So bad 10secs Blender crashes…)

But I’ll be looking forward to seeing the .blend…

just one quick question, if you drop the gun do you want to be able to pick it back up?

Nevermind I just did both,

This one you can pick up the cubes and it makes them on the empty and then you can pick up the other cube and it will replace the first cube.

ReplaceGun.blend (604 KB)

Then in this one when you pick up a second cube the first one gets dropped onto the ground and you can pick it back up if you wanted to.

SwitchGun.blend (614 KB)

The only difference from what you described as your logic bricks, is I used a ray sensor instead of a near sensor. You will have to be facing the gun(well Cube in the example) to pick it up.

I hope this helps, if you have any more questions, I will do my best to answer them. :slight_smile:

Alternatively you could have all the guns in your hand at the start and use the Visibility actuator to only show the one the player thinks he has. It’s very easy to do. If you want to make it look like you picked up something, just end the one on the ground and make the one in your hand visible. To drop something parent an empty a bit in front of your character and add whatever object your dropping. If you need any help don’t hesitate to ask.

You can do it that way but, I’m pretty sure that will be performance heavy, unless your only going to use to guns and that’s it.

Okay kevincorrigan thanks for the .blends.

@RossBlenderArt: I’ve tried that and ya hard on my CPU…But still looked wrong…

Please keep in mind that there will be 20+ guns (All different…) and sorry I haven’t replied to your post, I was at a family day at my local church…Happy times…

No problem, the method used in the replace gun blend would be best if you are going to implement an inventory, but the swap gun would be best for a game like call of duty, where you have certain weapons for primary weapons for primary and others for secondary weapons. In which, when you pick up a new primary weapon you drop your primary weapon and so forth.

I hope this helps:)

Okay I tried to remake the Switch.blend but something happen when I edited the script…

.blend http://www.pasteall.org/blend/13361

But the thing is, I think I coped everything like kevincorrigan .blend but something is just not right…

I made sure that I entered the SAME name in the script that I had the gun named… nothing…

Either its logic bricks or the script but one of them is messed up…

I’ll take a look

@kevincorrigan, yea that’s basically what I’m wanting to do…

I do, believe that I’ve fixed it. The main problems that I had to fix were:

  • you, didn’t finish naming everything

  • I had to move the ray from the player cube to a cube behind the camera that was parented to the camera, so that the ray would cast where the camera is facing. (I couldn’t, get it to work with the camera)

  • I had to move your “Gun”_UP Objects to a different layer and made 3 empties to spawn them once. This is so you can “Drop” the “Gun”_UP object and then pick it back up.

  • I moved your gun_Spawn empty further away from your player so that when you drop the gun it doesn’t spawn half inside of the player. (It was causing the guns to be thrown)

  • On your “Gun”_UP objects I would recommend that you go to the physics panel and increase the rotation Damping up to a Higher Value, and also click on the Lock rotation on the x and y axis, I think this will help when you drop the guns.

Here is the new blend:

Player.blend (1.1 MB)

If you need any more, just ask:)

I’ve been messing around with the original .blend that you posted, MouseDroid. Maybe I’m safe to assume that you’re somewhat new to Python, and you probably won’t understand all the Python stuff in this .blend (almost all of it is done with Python). However, maybe it will end up being helpful at some point. I probably overdid things a bit, but it works nicely.

E - pick up items
Q - drop currently held item
Scroll up/down - Switch weapons

Weapon_Switch_inventory.blend (155 KB)

@kevincorrigan: Oh wow I messed up bad… Thanks now on in the future I will know what i’m going to need to do…

@Riyuzakisan: Yes I’m new to Python but I did under stand a little bit of some of the scripts…And ya that’s what I was needing to have. Thank you so much Riyuzakisan and kevincorrigan for all of your help!

Marking this thread as SOLVED :smiley:

Edit: nvm…irrelevant and retarted :D:D

…sorry