- Home /
Weapon pick up and switching script
Can someone tell me how to make a weapon pickup script, to pick up weapons randomly on the map and later be able to switch them. I want to have a maximum of two guns you can switch(like in COD) and then resultly pick a new weapon up and replace with your gun you are holding. The thing is I have tried some many times to do this but I never came to a result. I would prefer C# since I am more familiar with it.
Thanks in advance
Post your script so far and we'll help you fix it. No one is going to write an entire script for you...
I posted my script at "Detecting Input from the start function (C#)" But I got no answers :)
what happens when you're in range for 2 weapons? How would you solve that?
Answer by NinjaSquirrel · May 07, 2011 at 11:10 PM
For picking up a weapon simply think like this:
- if someone touches this weapon
- ask the player if he wants to pick it up (GUI)
- if they say yes
- move the weapon to the player hand
For switching between them try thinking like this:
- when the player [link text][1] to switch weapons
- instantiate the respective primary or secondary weapon to the player.
No one is going to give you code like that, but what I said is how you should think about doing it.
I hope this helps, good luck!
[1]: http://unity3d.com/support/documentation/ScriptReference/Input.html 4. "pushes a certain button"
Answer by burgunfaust · May 08, 2011 at 03:18 PM
As far as changing weapons, look at this: http://answers.unity3d.com/questions/53579/turning-the-mesh-renderer-back-on-problem/53723#53723
Your answer
Follow this Question
Related Questions
Weapon Switching 1 Answer
Why doesn't this weapon switching script work 1 Answer
best way to weapon swapping 0 Answers
Switching/Picking up items in a third-person game 2 Answers
Cycling through enum with key press 1 Answer