Skip to content

Instantly share code, notes, and snippets.

@SenpaiRar
Last active May 1, 2019 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SenpaiRar/4f96567d14ae8fef5f69bdfcdee85570 to your computer and use it in GitHub Desktop.
Save SenpaiRar/4f96567d14ae8fef5f69bdfcdee85570 to your computer and use it in GitHub Desktop.
This is the script for weapons that are on the ground
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Weapon_Pickup : ClickableParent {
public Weapon_Template thisWeaponData;
public float MinimumDistance;
public override void OnClick(Vector3 ClickPosition)
{
if(Vector3.Distance(transform.position, ClickPosition) <= MinimumDistance){ //we check if the player is within distance
//We find the Player's gameoject and get the Weapon_Parent script on it. We then use the PickUpWeapon function and feed the Weapon_Template from this object
GameObject.Find("Player").GetComponent<Weapon_Parent>().PickUpWeapon(thisWeaponData);
Destroy(gameObject);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment