Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class PlayerGuns : MonoBehaviour
- {
- public int[] guns;
- public float numberofguns;
- public bool collidedwithcolt;
- public GameObject player;
- public GameObject hand;
- public GameObject dropit;
- public GameObject fakecoltprefab;
- public GameObject coltprefab;
- void Start ()
- {
- player = GameObject.Find("Player");
- }
- //if you collide guns, if you wanna create new ones just copy and paste with different tag
- void OnTriggerEnter(Collider other)
- {
- if(other.gameObject.tag == "Colt")
- {
- collidedwithcolt = true;
- }
- else
- {
- collidedwithcolt = false;
- }
- }
- void Update ()
- {
- //if you pickup a gun
- if (guns[0] == 0 && (Input.GetKey(KeyCode.E)) && collidedwithcolt == true)
- {
- GameObject fakecolt = Instantiate(fakecoltprefab) as GameObject;
- fakecolt.transform.parent = hand.transform;
- guns[0] = 1;
- }
- //drop a gun
- if (guns[0] == 1 && (Input.GetKey(KeyCode.Q)))
- {
- guns[0] = 0;
- GameObject colt = Instantiate(coltprefab) as GameObject;
- colt.transform.position = dropit.transform.position;
- }
- //set number of gun
- if (Input.GetKey(KeyCode.Alpha1))
- {
- numberofguns = 1;
- }
- if (Input.GetKey(KeyCode.Alpha2))
- {
- numberofguns = 2;
- }
- if (Input.GetKey(KeyCode.Alpha3))
- {
- numberofguns = 3;
- }
- }
- }
Advertisement
RAW Paste Data
Copied
Advertisement