Hello, I’m Lucas and my question is simple… Well, maybe not so simple, if it was, I would not ask it here…
I have a script that make I pick up my flashlight WHEN I walk next/over it, I want it to pick up the flashlight when I press the E key, but I already tried everything that I know.
The code I use to PickUp the flashlight (also the batteries for the flashlight):
using UnityEngine;
using System.Collections;
public class Pickup : MonoBehaviour
{
public enum Item
{
Flashlight,
Battery
}
public Item item;
void OnTriggerEnter()
{
if(item == Item.Flashlight)
{
Flashlight.HeadlightMount.SetActiveRecursively(false);
Flashlight.HeadlightMount.active = true;
HUD.HasFlashlight = true;
}
else
HUD.BatteryCount++;
Destroy(gameObject);
}
}
I think I need to edit the “OnTriggerEnter” to something with the key, right ?