Random Weapon Select, show gui on key press etc.

I need some help with something for my fps, i need to create a box which someone can walk up to and press a key which shows a gui, the gui will then show a weapon image and allow the player to take it, the gui then will need to disappear. I have some coding knowledge but do not fully understand how to do this.

1 Answer

1

Obviously this question is a bit general and I don’t know what setup you currently have, so I’ll give you a general idea.

  • So, I’m assuming by a box you mean a cube? Well, incorporate an OnTriggerStay which checks for a certain tag (of which the cube is tagged with) and for key input with:

if (collidername.collider.gameObject.CompareTag("tagname") && Input.GetKeyDown(KeyCode.//WhateverKeyYouWantToPress));

  • Then within this statement we would set a GUITexture to be enabled (which was previously false. Apply some function which will allow to ‘take’ the gun (can’t really help you since I don’t really know what you mean here) and then inside that function set the guiTexture.enabled to false.

Hope that was clear enough. Klep

.

If this answer helped you, could you accept it by pressing the tick?