Hello everyone, here is a script that is handling the aiming function of the player. The Player start aiming while i press the Fire2 button.
#endregion
#region Input Handle
bool wasCrouched = false;
Vector3 coverPositionBeforeAim;
void HandleInput()
{
if (IsDead)
return;
#region Common
if (CFInput.GetButton("Fire2") &&
WeaponId > 0 &&
!wasFalling &&
IsGrounded &&
!isPassingOver &&
!isSliding &&
(currentStateInfoTag(0) != RollHashTag && !isRolling && !isSliding && !IsReloading && currentStateInfoTag(2) != HealHashTag))//!IsInCover &&
{
if ((currentStateInfoTag(0) == CoverHashTag && !IsAimedInCover) || isAimingTransitionInCover)
{
IsAimed = false;
}
else
{
if (PWController.CurrentSelectedWeapon != null && PWController.CurrentSelectedWeapon.BulletType != TPSA_BulletType.Type.None)
{
if (CFInput.GetMouseButtonDown(2) && PWController.CurrentSelectedWeapon.UseScope)
PWController.ActivateScope = !PWController.ActivateScope;
if (PWController.CurrentSelectedWeapon.BulletType == TPSA_BulletType.Type.Grenade)
{
IsAimed = false;
IsHoldingGrenade = true;
}
else
{
IsHoldingGrenade = false;
IsAimed = true;
}
}
else
{
IsHoldingGrenade = false;
IsAimed = false;
}
}
}
else
{
//IsCrouched = false;
IsAimed = false;
IsHoldingGrenade = false;
}
But as soon as i stop pressing the Fire2 button, aiming stops. I dont want that. I want, once i press Fire2 button aiming will continue until i again press the Fire2 button. How can i do that??!!