From 228b4f7b2885222b29b0aaf92ed08d4f328711f2 Mon Sep 17 00:00:00 2001 From: Hazim Bin Ijaz Date: Thu, 9 Jan 2025 19:21:46 +0500 Subject: [PATCH] Update AbilitySystem.cs --- Assets/Scripts/Gameplay/AbilitySystem.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Gameplay/AbilitySystem.cs b/Assets/Scripts/Gameplay/AbilitySystem.cs index 9929c84..0074e9d 100644 --- a/Assets/Scripts/Gameplay/AbilitySystem.cs +++ b/Assets/Scripts/Gameplay/AbilitySystem.cs @@ -19,7 +19,7 @@ public class AbilitySystem : NetworkBehaviour [SerializeField] private GameObject wallIndicator; [Header("Wall Placement Settings")] - [SerializeField] private float wallRotationSpeed = 2f; + [SerializeField] private float wallRotationSpeed = 1.2f; private Vector3 wallSpawnPosition; private bool isWallPlacementStarted = false; @@ -111,11 +111,18 @@ public class AbilitySystem : NetworkBehaviour { if (isWallPlacementStarted && wallIndicator != null) { - float mouseX = Input.GetAxis("Mouse X"); - wallIndicator.transform.Rotate(Vector3.up, mouseX * wallRotationSpeed); // Rotate Y-axis based on mouse movement + Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); + if (Physics.Raycast(ray, out RaycastHit hit)) + { + Vector3 direction = (hit.point - wallIndicator.transform.position).normalized; + float angle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg; + Quaternion targetRotation = Quaternion.Euler(0f, angle, 0f); + wallIndicator.transform.rotation = Quaternion.Lerp(wallIndicator.transform.rotation, targetRotation, Time.deltaTime * wallRotationSpeed); + } } } + private void ManageStandardAbilityIndicator() { if (currentAbilityIndicator != null)