added scoring system for the bow game

This commit is contained in:
2025-05-20 14:53:35 +03:00
parent 03a3ca570e
commit ffd98b6322
36 changed files with 2275 additions and 84 deletions

View File

@@ -44,7 +44,7 @@ public class Menu : MonoBehaviour
openMenuAction.action.performed += ToggleMenu;
InputSystem.onDeviceChange += OnDeviceChange;
canvas = GetComponent<Canvas>();
canvas.enabled = false;
setCanvasVisibility(false);
}
public void DeactivateMenu() // Makes the ToggleMenu inable to toggle.
@@ -57,20 +57,37 @@ public class Menu : MonoBehaviour
activated = true;
}
public void setCanvasVisibility(bool enabled)
{
canvas.enabled = enabled;
}
private void ToggleMenu(InputAction.CallbackContext context)
{
if (!activated) return;
updateMenuTransform();
// Toggle the menu visibility
setCanvasVisibility(!canvas.enabled);
}
public Transform updateMenuTransform()
{
// Gets the transform of the menu Updates the transform along the way
// Does not enable its visibility.
// Get the camera's local Y rotation relative to the parent of MenuRotator
float relativeYRotation = Camera.transform.localEulerAngles.y;
// Apply the relative Y rotation to MenuRotator while keeping X and Z unchanged
MenuRotator.transform.localEulerAngles = new Vector3(0, relativeYRotation, 0);
// Set the menu position to match the camera's position in local space
MenuRotator.transform.position = Camera.transform.position;
MenuRotator.transform.position = Camera.transform.position;
return this.transform;
// Toggle the menu visibility
canvas.enabled = !canvas.enabled;
}
// Start is called before the first frame update