///────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── /// <summary> /// This method is used to activate the AIM mode when the right click is pressed /// </summary> public virtual void AimMode() { LookDirection(); if (InputAim.GetPressed != InputButton.Press) //If the Aim is set to One Click { if (InputAim.GetInput) //Get the AIM input { isAiming = !isAiming; //Toogle the Aim Mode aimSent = false; CurrentCameraSide = !CameraSide; //Camera Currentside = the opposite of the real CamSide to be able to enter in a state while Aiming } } else //If the Aim is set to Pressed { if (isAiming != InputAim.GetInput) { isAiming = InputAim.GetInput; //is Aiming will be equal to the Input Entry aimSent = false; } } if (isAiming) { Transform origin = ActiveAbility.AimRayOrigin(); //Gets the Origing from where is going to Start the Ray Aim; if (AimDot) { AimDot.gameObject.SetActive(true); } if (Target) { aimDirection = Utilities.MalbersTools.DirectionTarget(origin, Target); } else { Vector3 screenTarget = AimDot != null ? AimDot.position : new Vector3(Screen.width * 0.5f, Screen.height * 0.5f); //Gets the Center of the Aim Dot Transform aimDirection = Utilities.MalbersTools.DirectionFromCamera(origin, screenTarget, out aimRayHit, HitMask); } if (debug) { Debug.DrawLine(origin.position, AimRayCastHit.point, Color.red); // Debug.DrawRay(origin.position, aimDirection * 50, Color.red); } if (CurrentCameraSide != CameraSide) //Reset AimSent Values { aimSent = false; } if (CameraSide && !aimSent) //Change the camera to the Right Side { if (!(!ActiveAbility.ChangeAimCameraSide() && Active_IMWeapon.RightHand)) //Prevent the Camera Swap if is Using A Bow { SetAim(true); } else { SetAim(false); } } else if (!CameraSide && !aimSent) //Change the camera to the Left Side { if (!(!ActiveAbility.ChangeAimCameraSide() && !Active_IMWeapon.RightHand)) //Prevent the Camera Swap if is Using A Bow { SetAim(false); } else { SetAim(true); } } if (rider.Montura != null) { rider.Montura.StraightAim(true); //MountPoint.rotation = // Quaternion.FromToRotation(rider.Montura.transform.up, Vector3.up) * rider.Montura.MountPoint.rotation; //Keep a Straight Spine while Aiming } } else //If is not Aiming go to IsMounted Camera State { if (!aimSent) { aimSent = true; CurrentCameraSide = !CameraSide; // Camera Currentside = the opposite of the real CamSide to be able to enter in a state while Aiming SetAction(WeaponActions.Idle); //Sent Action to Idle again OnAimSide.Invoke(0); //Send that is not aiming anymore if (AimDot) { AimDot.gameObject.SetActive(false); //Hide the AimDot; } rider.Montura.StraightAim(false); //MountPoint.localRotation = MountStartRotation; if ((_weaponAction == WeaponActions.AimLeft || _weaponAction == WeaponActions.AimRight || WeaponAction == WeaponActions.Hold || WeaponAction == WeaponActions.Fire_Proyectile)) //Fix theACtion if is not Aiming { SetAction(IsInCombatMode ? WeaponActions.Idle : WeaponActions.None); } } } }