Guys can you tell me how do you make aiming in your fps projects?

Hi everyone,

I’ve tried several YouTube tutorials, and while they weren’t necessarily wrong, they didn’t fully address my issue. The problem is that I don’t just need an aiming feature—I also need to be able to shoot while aiming, and I can’t find a tutorial that covers this.

I’ve even tried using ChatGPT for help, but it didn’t fully resolve my problem. Could anyone share the methods or approaches you use for this?

To clarify, I’m not looking for scope aiming (like sniper scopes); I need an aim-down-sights (ADS) system. Later, I plan to add scopes and similar mechanics, but for now, I’m focused on getting basic ADS with shooting functionality working.

Thanks in advance!

here i have some code

using UnityEngine;

public class AimScript : MonoBehaviour
{
    public Animator animator; // Animator-ul asociat personajului
    public string aimParameter = "isAiming"; // Numele parametrului pentru animația de țintire
    public string fireTrigger = "Fire"; // Trigger pentru animația de tragere normală
    public string aimFireTrigger = "AimFire"; // Trigger pentru animația de tragere în timp ce țintești
    public KeyCode aimKey = KeyCode.Mouse1; // Tasta pentru a activa țintirea (clic dreapta)
    public KeyCode fireKey = KeyCode.Mouse0; // Tasta pentru tragere (clic stânga)

    private bool isAiming = false; // Starea curentă de țintire

    void Update()
    {
        // Clic dreapta (Mouse1) - Țintire (Aiming)
        if (Input.GetKeyDown(aimKey))
        {
            isAiming = true;
            animator.SetBool(aimParameter, isAiming);
            Debug.Log("Mouse1 apăsat: Aiming activat.");
        }

        // Eliberare clic dreapta (Mouse1)
        if (Input.GetKeyUp(aimKey))
        {
            isAiming = false;
            animator.SetBool(aimParameter, isAiming);
            Debug.Log("Mouse1 eliberat: Aiming dezactivat.");
        }

        // Clic stânga (Mouse0) - Fire sau AimFire
        if (Input.GetKeyDown(fireKey))
        {
            if (isAiming)
            {
                // Dacă ești în modul de țintire, reda animația AimFire
                animator.SetTrigger(aimFireTrigger);
                Debug.Log("Mouse0 apăsat: AimFire redat (tragere în timp ce țintești).");
            }
            else
            {
                // Dacă nu ești în modul de țintire, reda animația Fire
                animator.SetTrigger(fireTrigger);
                Debug.Log("Mouse0 apăsat: Fire redat (tragere normală).");
            }
        }
    }
}