diff --git a/RunningLateGame/Assets/Scripts/MarkPlayer.cs b/RunningLateGame/Assets/Scripts/MarkPlayer.cs
deleted file mode 100644
index 6c46e29..0000000
--- a/RunningLateGame/Assets/Scripts/MarkPlayer.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * author: mark joshwel
- * date: 27/5/2024
- * description: script for handling player interactivity
- */
-
-using UnityEngine;
-
-///
-/// class for handling player interactivity
-///
-public class MarkPlayer : MonoBehaviour
-{
- ///
- /// game manager instance
- ///
- private GameManager _game;
-
- ///
- /// initialisation function
- ///
- private void Start()
- {
- _game = GameManager.Instance;
- }
-
- ///
- /// function called by the input system when escape is paused
- ///
- public void OnPause()
- {
- Debug.Log("escape pressed");
- _game.SetDisplayState(_game.Paused ? GameManager.DisplayState.Game : GameManager.DisplayState.OverlayPauseMenu);
- }
-}
\ No newline at end of file
diff --git a/RunningLateGame/Assets/Scripts/MarkPlayer.cs.meta b/RunningLateGame/Assets/Scripts/MarkPlayer.cs.meta
deleted file mode 100644
index 011254f..0000000
--- a/RunningLateGame/Assets/Scripts/MarkPlayer.cs.meta
+++ /dev/null
@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: 995d26dc842b43269f0cfd51fe4e32ef
-timeCreated: 1723266626
\ No newline at end of file
diff --git a/RunningLateGame/Assets/Scripts/Player.cs b/RunningLateGame/Assets/Scripts/Player.cs
index 719bd7e..46a5493 100644
--- a/RunningLateGame/Assets/Scripts/Player.cs
+++ b/RunningLateGame/Assets/Scripts/Player.cs
@@ -1,53 +1,61 @@
/*
- * author: ryan lin
- * date: 8/8/2024
- * description: TODO
+ * author: ryan lin, mark joshwel
+ * date: 11/8/2024
+ * description: player interaction behaviour
*/
using UnityEngine;
///
-/// TODO
+/// player interaction behaviour
///
public class Player : MonoBehaviour
{
///
- /// TODO
+ /// the position of the player
///
[SerializeField] private Transform playerPosition;
///
- /// TODO
+ /// the maximum distance the player can interact with objects
///
- [SerializeField] private float seeDistance;
+ [SerializeField] private float interactableDistance;
///
- /// TODO
+ /// the layers the raycast should interact with
///
public LayerMask raycastLayers;
- ///
- /// TODO
- ///
- private bool _active;
+ // ///
+ // /// the current interactable object the player is looking at
+ // ///
+ // private CommonInteractable _currentInteractable;
///
- /// TODO
+ /// game manager instance
///
- private CommonInteractable _currentInteractable;
+ private GameManager _game;
///
- /// TODO
+ /// whether the player is looking at an interactable object
///
private bool _raycast;
///
- /// TODO
+ /// the raycast hit information
///
public RaycastHit Hit;
///
- /// TODO
+ /// initialisation function
+ ///
+ private void Start()
+ {
+ _game = GameManager.Instance;
+ }
+
+ ///
+ /// raycast performer for interactable objects
///
private void Update()
{
@@ -55,24 +63,41 @@ private void Update()
playerPosition.position,
playerPosition.TransformDirection(Vector3.forward),
out Hit,
- seeDistance,
+ interactableDistance,
raycastLayers
);
Debug.DrawRay(
playerPosition.position,
- playerPosition.TransformDirection(Vector3.forward) * seeDistance,
+ playerPosition.TransformDirection(Vector3.forward) * interactableDistance,
Color.green
);
+
+ if (!_raycast) return;
+
+ // show an interaction prompt if we're looking at an interactable object
+ var prompt = Hit.collider.GetComponent()?.interactionPrompt;
+ if (prompt != "")
+ {
+ Debug.Log(prompt);
+ }
}
///
- /// TODO
+ /// handles the action when the player interacts with an object
///
private void OnAction()
{
- Debug.Log("test");
- if (_raycast)
- if (Hit.transform.CompareTag("Interactable"))
- Hit.transform.GetComponent().Interact();
+ if (!_raycast) return;
+ Hit.collider.GetComponent()?.Interact();
+ // _currentInteractable?.Interact();
+ }
+
+ ///
+ /// function called by the input system when escape is paused
+ ///
+ public void OnPause()
+ {
+ Debug.Log("escape pressed");
+ _game.SetDisplayState(_game.Paused ? GameManager.DisplayState.Game : GameManager.DisplayState.OverlayPauseMenu);
}
}
\ No newline at end of file