How do i make on object pickable on button and from certian distance?
now it works onTrigger
using UnityEngine;
using System.Collections;
public class BatteryPickUp : MonoBehaviour {
public bool removeOnUse = true;
//for late ruse
public AudioClip pickupSound;
public AudioClip fullSound;
void OnTriggerEnter(Collider other) {
if (other.gameObject.tag == "Player") {
Flashlight flashlightscript = Camera.main.gameObject.GetComponent<Flashlight>();
flashlightscript.AddBattery();
if(removeOnUse){
Object.Destroy(gameObject);
}
}
}
}
thank you so mouch ! it works perfectly ! now when i look on object it gives battery and get destroyed! now i can adjust on how i want it to work exactly!