|
Hi there I am planning on having around 15 different guns within my game and am wondering how to change weapons from the one in my hand to a weapon on the ground. I have a firing/ammo script for my guns and I have a gun swapping script that I made:
the problem is that this script that I made-up only works for two guns and I need to swap between around 15 eventually. I know I could extend this script to work for more guns but I'm worried it would get very complicated and slow functioning. Any help would be much appreciated Thanks, Scribe (javascript please)
(comments are locked)
|
|
You are testing against a particular gun that you have to assign to your player. Just tag your guns as "Gun" and do something like that:
When hitting the "Q" button it iterated through all colliders that are in range (dist). If it found a gameObject that is tagged as "Gun" and it's not the one you're using at the moment. switch them. thanks worked great
Mar 01 '11 at 04:50 PM
Scribe
(comments are locked)
|
|
Make an array of guns, and just have it change due to amount, and have a switch statement for certain values... A = 0, B=1, C=2, D=3. Switch so that if A, gun value = 0, and so you change var gun to that gun, and all the properties... B has value = 1 etc. Kind of easy.
(comments are locked)
|
