This repository has been archived on 2024-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
sota/RunningLateGame/Assets/Scripts/Player.cs

42 lines
1 KiB
C#
Raw Normal View History

using UnityEngine;
public class Player : MonoBehaviour
{
public RaycastHit Hit;
[SerializeField] private Transform playerPosition;
[SerializeField] private float seeDistance;
private Interactable _currentInteractable;
private bool _active;
private bool _raycast;
public LayerMask raycastLayers;
private void Update()
{
_raycast = Physics.Raycast(
playerPosition.position,
playerPosition.TransformDirection(Vector3.forward),
out Hit,
seeDistance,
raycastLayers
);
Debug.DrawRay(
playerPosition.position,
playerPosition.TransformDirection(Vector3.forward) * seeDistance,
Color.green
);
}
private void OnAction()
{
Debug.Log("test");
if (_raycast)
{
if (Hit.transform.CompareTag("Interactable"))
{
Hit.transform.GetComponent<Interactable>().Interact();
}
}
}
}