Hey everyone , I’m making a game and I want to change my pick up system a little bit.
there is my script :
using UnityEngine;
using System.Collections.Generic;
public class Keyring : MonoBehaviour
{
public AudioClip getKeySound;
public float keyPickUpDistance = 5f;
private List _keys = new List();
public void AddKey(Key key)
{
_keys.Add(key);
if (getKeySound != null)
{
audio.PlayOneShot(getKeySound);
}
}
public bool HasKey(Key key)
{
return _keys.Contains(key);
}
void Update()
{
if (Input.GetKeyDown(KeyCode.E))
{
RaycastHit hit;
if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, keyPickUpDistance))
{
Key key = hit.transform.GetComponent();
if (key != null)
{
AddKey(key);
key.transform.parent = transform;
key.transform.localPosition = Vector3.zero;
key.gameObject.SetActiveRecursively(false);
}
}
}
}
}
(Attached to my Player)
I’m trying to create a function , when I press the USE key(E) I want it to ask me if I actually want to pick up this items or no like in silent hill 1.
Can anyone help me with that ?
Thank you for your time =)