I am activating and deactivating my guns on collision to create a weapon pick up feature. For example the Player starts with no gun because they are all deactivated on start, but if he collides with an object with a tag of say UZI that gun will become active, keeping all the other guns deactivated. This doesnt work how I would of thought, instead it only activates the M14 keeping everything else deactivated no matter which tagged object I collide with. I hope you understand my script better than my explanation, hope someone can help.
var glock : GameObject;
var UZI : GameObject;
var G36C : GameObject;
var M14 : GameObject;
function Start () {
UZI.active = false;
glock.active = false;
G36C.active = false;
M14.active = false;
}
function OnCollisionEnter(collision: Collision) {
if (collision.gameObject.tag == "UZI");
UZI.active = true;
glock.active = false;
G36C.active = false;
M14.active = false;
if (collision.gameObject.tag == "glock");
UZI.active = false;
glock.active = true;
G36C.active = false;
M14.active = false;
if (collision.gameObject.tag == "G36C");
UZI.active = false;
glock.active = false;
G36C.active = true;
M14.active = false;
if (collision.gameObject.tag == "M14");
UZI.active = false;
glock.active = false;
G36C.active = false;
M14.active = true;
}