feat: Debug Raycasts of Weapon

This commit is contained in:
Константин Адер 2024-12-06 02:31:11 +03:00
parent a9d662750c
commit 41ad534a7a
2 changed files with 9 additions and 0 deletions

View File

@ -251,6 +251,7 @@ public class RobotController : NetworkBehaviour
protected void ShootServerRPC() protected void ShootServerRPC()
{ {
Debug.Log($"Shooting triggered. Owner: {OwnerClientId}"); Debug.Log($"Shooting triggered. Owner: {OwnerClientId}");
weapon.Shooting();
} }
[ServerRpc] [ServerRpc]

View File

@ -5,6 +5,8 @@ public class Weapon : MonoBehaviour
// [SerializeField] private float damage = 10f; // [SerializeField] private float damage = 10f;
[SerializeField] private float range = 100f; [SerializeField] private float range = 100f;
[SerializeField] protected Camera mainCam; [SerializeField] protected Camera mainCam;
[SerializeField] protected float debugRayDistance = 5f;
[SerializeField] protected float debugRayDuration = 2f;
public void Shooting() public void Shooting()
{ {
@ -12,6 +14,12 @@ public class Weapon : MonoBehaviour
if (Physics.Raycast(mainCam.transform.position, mainCam.transform.forward, out hit, range)) if (Physics.Raycast(mainCam.transform.position, mainCam.transform.forward, out hit, range))
{ {
Debug.Log(hit.transform.name); Debug.Log(hit.transform.name);
Vector3 rayDir = mainCam.transform.forward * debugRayDistance;
Debug.DrawRay(mainCam.transform.position, rayDir, Color.yellow, debugRayDuration, false);
} }
} }
// Debug Shooting
} }