Ive been trying to add this feature to my game for a very long time now with no luck what so ever.
What I am wanting to do is start my game with the player holding a gun, the gun being a child of the main camera and being tagged as gun1. When the player collides with an object on the ground tagged as gun2 they swap around, so gun1 is now the object on the ground and gun2 is the child of the main camera. There will also be gun3 and gun4, but the principle is which ever gun you collide with it swaps with the gun attached to the main camera. Can someone help me with this please?
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;
}
Yeah Ive looked at a lot of other questions similar to mine but they are asking for different things that I cant change to fit what Im trying to do.
– Blink