unity gun pickup script 2d code example
Example: unity 2d gun pickup
public gameobject AK47; void Update() { if (Input.GetButton("Interact")) { UseItemRay = new Ray(PlayerCam.transform.position, PlayerCam.transform.forward); if (Physics.Raycast(UseItemRay, out Hit, 10)) { if (Hit.collider.tag == "Pickup") { if hit.collider.name = "AK47" { ak47.setactive(true); } } } } }