Started working on turrets

This commit is contained in:
2026-01-13 17:33:30 +00:00
parent 44ef19d058
commit 6f31012cd8
93 changed files with 72145 additions and 7 deletions

View File

@@ -0,0 +1,75 @@
using UnityEngine;
using TMPro;
using StarterAssets;
public class Interaction : MonoBehaviour, IInteractable
{
[SerializeField] TextMeshProUGUI interactionPrompt;
[SerializeField] float interactRange = 3f;
StarterAssetsInputs starterAssetsInputs;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
starterAssetsInputs = GetComponent<StarterAssetsInputs>();
interactionPrompt.gameObject.SetActive(false);
interactionPrompt.text ="";
}
// Update is called once per frame
void Update()
{
RaycastHit hit;
if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, interactRange))
{
IInteractable interactable = hit.transform.GetComponent<IInteractable>();
if (interactable != null)
{
interactionPrompt.gameObject.SetActive(true);
interactionPrompt.text = interactable.GetInteractionPrompt();
//Debug.Log("Looking at interactable: " + hit.transform.name);
if (!starterAssetsInputs.interact) return;
{
interactable.Interact(gameObject);
interactionPrompt.gameObject.SetActive(false);
starterAssetsInputs.InteractInput(false);
}
interactionPrompt.gameObject.SetActive(false);
}
else
{
interactionPrompt.gameObject.SetActive(false);
interactionPrompt.text = "";
}
}
else
{
interactionPrompt.gameObject.SetActive(false);
interactionPrompt.text = "";
}
}
public void Interact(GameObject interactor)
{
Debug.Log("Interacted with " + gameObject.name);
}
public bool CanInteract(GameObject interactor)
{
throw new System.NotImplementedException();
}
public string GetInteractionPrompt()
{
throw new System.NotImplementedException();
}
public void OnHighlight()
{
throw new System.NotImplementedException();
}
public void OnUnhighlight()
{
throw new System.NotImplementedException();
}
}