|
TopDown Engine v4.5
|
Public Types | |
| enum | AimControls { Off , PrimaryMovement , SecondaryMovement , Mouse , Script , SecondaryThenPrimaryMovement , PrimaryThenSecondaryMovement , CharacterRotateCameraDirection } |
| the list of possible control modes More... | |
| enum | RotationModes { Free , Strict2Directions , Strict4Directions , Strict8Directions } |
| the list of possible rotation modes More... | |
| enum | ReticleTypes { None , Scene , UI } |
| the possible types of reticles More... | |
Public Member Functions | |
| virtual void | ApplyAim () |
| virtual void | SetCurrentAim (Vector3 newAim, bool setAimAsLastNonNullMovement=false) |
| Aims the weapon towards a new point. | |
| virtual Vector3 | GetReticlePosition () |
| Returns the position of the reticle. | |
| virtual Vector3 | GetMousePosition () |
| Returns the current mouse position. | |
| virtual void | RemoveReticle () |
| Removes any remaining reticle. | |
| virtual void | AddAdditionalAngle (float addedAngle) |
| Adds additional angle to the weapon's rotation. | |
| void | OnMMEvent (TopDownEngineEvent engineEvent) |
| Public Member Functions inherited from MoreMountains.Tools.MMEventListener< T > | |
| void | OnMMEvent (T eventType) |
Public Attributes | |
| AimControls | AimControl = AimControls.SecondaryMovement |
| the aim control mode | |
| bool | AimControlActive = true |
| if this is true, this script will be able to read input from its specified AimControl mode | |
| RotationModes | RotationMode = RotationModes.Free |
| the rotation mode | |
| float | WeaponRotationSpeed = 1f |
| the the speed at which the weapon reaches its new position. Set it to zero if you want movement to directly follow input | |
| bool | ClampAngle = false |
| if this is true, aim angle will be clamped between MinimumAngle and MaximumAngle | |
| float | MinimumAngle = -180f |
| the minimum angle at which the weapon's rotation will be clamped | |
| float | MaximumAngle = 180f |
| the maximum angle at which the weapon's rotation will be clamped | |
| float | MinimumMagnitude = 0.2f |
| the minimum threshold at which the weapon's rotation magnitude will be considered | |
| ReticleTypes | ReticleType = ReticleTypes.None |
| Defines whether the reticle is placed in the scene or in the UI. | |
| GameObject | Reticle |
| the gameobject to display as the aim's reticle/crosshair. Leave it blank if you don't want a reticle | |
| float | ReticleDistance |
| the distance at which the reticle will be from the weapon | |
| float | ReticleHeight |
| the height at which the reticle should position itself above the ground, when in Scene mode | |
| bool | ReticleAtMousePosition |
| if set to true, the reticle will be placed at the mouse's position (like a pointer) | |
| bool | RotateReticle = false |
| if set to true, the reticle will rotate on itself to reflect the weapon's rotation. If not it'll remain stable. | |
| bool | ReplaceMousePointer = true |
| if set to true, the reticle will replace the mouse pointer | |
| float | MouseDeadZoneRadius = 0.5f |
| the radius around the weapon rotation centre where the mouse will be ignored, to avoid glitches | |
| bool | DisplayReticle = true |
| if set to false, the reticle won't be added and displayed | |
| bool | MoveCameraTargetTowardsReticle = false |
| whether the camera target should be moved towards the reticle to provide a better vision of the possible target. If you don't have a reticle, it'll be moved towards your aim direction. | |
| float | CameraTargetOffset = 0.3f |
| the offset to apply to the camera target along the transform / reticle line | |
| float | CameraTargetMaxDistance = 10f |
| the maximum distance at which to move the camera target | |
| float | CameraTargetSpeed = 5f |
| the speed at which the camera target should be moved | |
Protected Member Functions | |
| virtual void | Start () |
| On Start(), we trigger the initialization. | |
| virtual void | Initialization () |
| Grabs the weapon component, initializes the angle values. | |
| virtual void | GetCurrentAim () |
| virtual void | Update () |
| Every frame, we compute the aim direction and rotate the weapon accordingly. | |
| virtual void | LateUpdate () |
| On LateUpdate, resets any additional angle. | |
| virtual void | DetermineWeaponRotation () |
| Determines the weapon's rotation. | |
| virtual void | MoveReticle () |
| Moves the weapon's reticle. | |
| virtual void | RotateWeapon (Quaternion newRotation, bool forceInstant=false) |
| Rotates the weapon, optionnally applying a lerp to it. | |
| virtual void | AimAt (Vector3 target) |
| virtual void | InitializeReticle () |
| If a reticle has been set, instantiates the reticle and positions it. | |
| virtual void | MoveTarget () |
| This method defines how the character's camera target should move. | |
| virtual void | HideReticle () |
| Hides (or shows) the reticle based on the DisplayReticle setting. | |
| virtual void | HideMousePointer () |
| Hides or show the mouse pointer based on the settings. | |
| void | OnDestroy () |
| On Destroy, we reinstate our cursor if needed. | |
| virtual void | ResetAdditionalAngle () |
| Resets the additional angle. | |
| virtual void | AutoDetectWeaponMode () |
| virtual void | OnEnable () |
| On enable we start listening for events. | |
| virtual void | OnDisable () |
| On disable we stop listening for events. | |
Protected Attributes | |
| Camera | _mainCamera |
| Vector2 | _lastNonNullMovement |
| Weapon | _weapon |
| Vector3 | _currentAim = Vector3.zero |
| Vector3 | _currentAimAbsolute = Vector3.zero |
| Quaternion | _lookRotation |
| Vector3 | _direction |
| float[] | _possibleAngleValues |
| Vector3 | _mousePosition |
| Vector3 | _lastMousePosition |
| float | _additionalAngle |
| Quaternion | _initialRotation |
| Plane | _playerPlane |
| GameObject | _reticle |
| Vector3 | _reticlePosition |
| Vector3 | _newCamTargetPosition |
| Vector3 | _newCamTargetDirection |
| bool | _initialized = false |
| Vector3 | _aimAtDirection |
| Quaternion | _aimAtQuaternion |
Properties | |
| virtual float | CurrentAngleAbsolute [get, protected set] |
| virtual Quaternion | CurrentRotation [get] |
| the weapon's current rotation | |
| virtual Vector3 | CurrentAim [get] |
| the weapon's current direction | |
| virtual Vector3 | CurrentAimAbsolute [get] |
| the weapon's current direction, absolute (flip independent) | |
| virtual float | CurrentAngle [get, protected set] |
| the current angle the weapon is aiming at | |
| virtual float | CurrentAngleRelative [get] |
| the current angle the weapon is aiming at, adjusted to compensate for the current orientation of the character | |
| virtual GameObject | ReticleInstance [get] |
| the instance of the reticle in the scene, if this weapon has one | |
| virtual Weapon | TargetWeapon [get] |
|
virtual |
Adds additional angle to the weapon's rotation.
| addedAngle |
|
protectedvirtual |
Reimplemented in MoreMountains.TopDownEngine.WeaponAim3D.
|
virtual |
|
protectedvirtual |
|
protectedvirtual |
Determines the weapon's rotation.
Reimplemented in MoreMountains.TopDownEngine.WeaponAim2D, and MoreMountains.TopDownEngine.WeaponAim3D.
|
protectedvirtual |
Reimplemented in MoreMountains.TopDownEngine.WeaponAim2D, and MoreMountains.TopDownEngine.WeaponAim3D.
|
virtual |
Returns the current mouse position.
|
virtual |
Returns the position of the reticle.
|
protectedvirtual |
Hides or show the mouse pointer based on the settings.
|
protectedvirtual |
Hides (or shows) the reticle based on the DisplayReticle setting.
|
protectedvirtual |
Grabs the weapon component, initializes the angle values.
Reimplemented in MoreMountains.TopDownEngine.WeaponAim2D, and MoreMountains.TopDownEngine.WeaponAim3D.
|
protectedvirtual |
If a reticle has been set, instantiates the reticle and positions it.
Reimplemented in MoreMountains.TopDownEngine.WeaponAim2D, and MoreMountains.TopDownEngine.WeaponAim3D.
|
protectedvirtual |
On LateUpdate, resets any additional angle.
|
protectedvirtual |
Moves the weapon's reticle.
Reimplemented in MoreMountains.TopDownEngine.WeaponAim2D, and MoreMountains.TopDownEngine.WeaponAim3D.
|
protectedvirtual |
This method defines how the character's camera target should move.
Reimplemented in MoreMountains.TopDownEngine.WeaponAim2D, and MoreMountains.TopDownEngine.WeaponAim3D.
|
protected |
On Destroy, we reinstate our cursor if needed.
|
protectedvirtual |
On disable we stop listening for events.
|
protectedvirtual |
On enable we start listening for events.
| void MoreMountains.TopDownEngine.WeaponAim.OnMMEvent | ( | TopDownEngineEvent | engineEvent | ) |
|
virtual |
Removes any remaining reticle.
|
protectedvirtual |
Resets the additional angle.
|
protectedvirtual |
Rotates the weapon, optionnally applying a lerp to it.
| newRotation | New rotation. |
|
virtual |
Aims the weapon towards a new point.
| newAim | New aim. |
Reimplemented in MoreMountains.TopDownEngine.WeaponAim2D, and MoreMountains.TopDownEngine.WeaponAim3D.
|
protectedvirtual |
On Start(), we trigger the initialization.
|
protectedvirtual |
Every frame, we compute the aim direction and rotate the weapon accordingly.
Reimplemented in MoreMountains.TopDownEngine.WeaponAim2D, and MoreMountains.TopDownEngine.WeaponAim3D.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
| AimControls MoreMountains.TopDownEngine.WeaponAim.AimControl = AimControls.SecondaryMovement |
the aim control mode
| bool MoreMountains.TopDownEngine.WeaponAim.AimControlActive = true |
if this is true, this script will be able to read input from its specified AimControl mode
| float MoreMountains.TopDownEngine.WeaponAim.CameraTargetMaxDistance = 10f |
the maximum distance at which to move the camera target
| float MoreMountains.TopDownEngine.WeaponAim.CameraTargetOffset = 0.3f |
the offset to apply to the camera target along the transform / reticle line
| float MoreMountains.TopDownEngine.WeaponAim.CameraTargetSpeed = 5f |
the speed at which the camera target should be moved
| bool MoreMountains.TopDownEngine.WeaponAim.ClampAngle = false |
if this is true, aim angle will be clamped between MinimumAngle and MaximumAngle
| bool MoreMountains.TopDownEngine.WeaponAim.DisplayReticle = true |
if set to false, the reticle won't be added and displayed
| float MoreMountains.TopDownEngine.WeaponAim.MaximumAngle = 180f |
the maximum angle at which the weapon's rotation will be clamped
| float MoreMountains.TopDownEngine.WeaponAim.MinimumAngle = -180f |
the minimum angle at which the weapon's rotation will be clamped
| float MoreMountains.TopDownEngine.WeaponAim.MinimumMagnitude = 0.2f |
the minimum threshold at which the weapon's rotation magnitude will be considered
| float MoreMountains.TopDownEngine.WeaponAim.MouseDeadZoneRadius = 0.5f |
the radius around the weapon rotation centre where the mouse will be ignored, to avoid glitches
| bool MoreMountains.TopDownEngine.WeaponAim.MoveCameraTargetTowardsReticle = false |
whether the camera target should be moved towards the reticle to provide a better vision of the possible target. If you don't have a reticle, it'll be moved towards your aim direction.
| bool MoreMountains.TopDownEngine.WeaponAim.ReplaceMousePointer = true |
if set to true, the reticle will replace the mouse pointer
| GameObject MoreMountains.TopDownEngine.WeaponAim.Reticle |
the gameobject to display as the aim's reticle/crosshair. Leave it blank if you don't want a reticle
| bool MoreMountains.TopDownEngine.WeaponAim.ReticleAtMousePosition |
if set to true, the reticle will be placed at the mouse's position (like a pointer)
| float MoreMountains.TopDownEngine.WeaponAim.ReticleDistance |
the distance at which the reticle will be from the weapon
| float MoreMountains.TopDownEngine.WeaponAim.ReticleHeight |
the height at which the reticle should position itself above the ground, when in Scene mode
| ReticleTypes MoreMountains.TopDownEngine.WeaponAim.ReticleType = ReticleTypes.None |
Defines whether the reticle is placed in the scene or in the UI.
| bool MoreMountains.TopDownEngine.WeaponAim.RotateReticle = false |
if set to true, the reticle will rotate on itself to reflect the weapon's rotation. If not it'll remain stable.
| RotationModes MoreMountains.TopDownEngine.WeaponAim.RotationMode = RotationModes.Free |
the rotation mode
| float MoreMountains.TopDownEngine.WeaponAim.WeaponRotationSpeed = 1f |
the the speed at which the weapon reaches its new position. Set it to zero if you want movement to directly follow input
|
get |
the weapon's current direction
|
get |
the weapon's current direction, absolute (flip independent)
|
getprotected set |
the current angle the weapon is aiming at
|
getprotected set |
|
get |
the current angle the weapon is aiming at, adjusted to compensate for the current orientation of the character
|
get |
the weapon's current rotation
|
get |
the instance of the reticle in the scene, if this weapon has one
|
get |