Exemplo n.º 1
0
 private void AimWeapon(PlayerAimInputs playerAimInputs)
 {
     if (Math.Abs(playerAimInputs.AimXAxis) > 0.01f && Math.Abs(playerAimInputs.AimYAxis) > 0.01f)
     {
         UpdateWeaponPosition(playerAimInputs);
         UpdateWeaponRotation(playerAimInputs);
     }
 }
Exemplo n.º 2
0
    private void UpdateWeaponPosition(PlayerAimInputs playerAimInputs)
    {
        Vector3 aimVector = new Vector3(playerAimInputs.AimXAxis, -playerAimInputs.AimYAxis, 0.0f);

        if (aimVector.magnitude > 0.0f)
        {
            aimVector.Normalize();
        }
        aimVector = aimVector * 0.5f;
        transform.localPosition = aimVector;
    }
Exemplo n.º 3
0
    private void UpdateWeaponRotation(PlayerAimInputs playerAimInputs)
    {
        float rotationDegrees = 180 + Mathf.Rad2Deg * Mathf.Atan2(playerAimInputs.AimXAxis, playerAimInputs.AimYAxis);

        transform.localRotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, rotationDegrees));
    }
Exemplo n.º 4
0
    public override void Aim()
    {
        PlayerAimInputs playerAimInputs = new PlayerAimInputs(playerId);

        AimWeapon(playerAimInputs);
    }