Update AbilitySystem.cs

dev-hazim
Hazim Bin Ijaz 1 week ago
parent 3fd839b155
commit 228b4f7b28

@ -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)

Loading…
Cancel
Save