|
TopDown Engine v4.5
|
The 2D version of the WeaponAutoAim, meant to be used on objects equipped with a WeaponAim2D. It'll detect targets within the defined radius, pick the closest, and force the WeaponAim component to aim at them if a target is found. More...
Public Attributes | |
| int | OverlapMaximum = 10 |
| the maximum amount of targets the overlap detection can acquire | |
| Public Attributes inherited from MoreMountains.TopDownEngine.WeaponAutoAim | |
| LayerMask | TargetsMask |
| the layermask on which to look for aim targets | |
| LayerMask | ObstacleMask = LayerManager.ObstaclesLayerMask |
| the layermask on which to look for obstacles | |
| float | ScanRadius = 15f |
| the radius (in units) around the character within which to search for targets | |
| Vector2 | LineOfFireBoxcastSize = new Vector2(0.1f, 0.1f) |
| the size of the boxcast that will be performed to verify line of fire | |
| float | DurationBetweenScans = 1f |
| the duration (in seconds) between 2 scans for targets | |
| Vector3 | DetectionOriginOffset = Vector3.zero |
| an offset to apply to the weapon's position for scan | |
| bool | OnlyAcquireTargetsIfOwnerIsIdle = false |
| if this is true, auto aim scan will only acquire new targets if the owner is in the idle state | |
| WeaponAim.RotationModes | RotationMode |
| the rotation mode to apply when a target is found | |
| bool | ApplyAutoAimAsLastDirection = true |
| if this is true, the auto aim direction will also be passed as the last non null direction, so the weapon will keep aiming in that direction should the target be lost | |
| bool | MoveCameraTarget = true |
| whether or not this component should take control of the camera target when a camera is found | |
| float | CameraTargetDistance = 0.5f |
| the normalized distance (between 0 and 1) at which the camera target should be, on a line going from the weapon owner (0) to the auto aim target (1) | |
| float | CameraTargetMaxDistance = 10f |
| the maximum distance from the weapon owner at which the camera target can be | |
| float | CameraTargetSpeed = 5f |
| the speed at which to move the camera target | |
| bool | MoveCameraToCharacterIfNoTarget = false |
| if this is true, the camera target will move back to the character if no target is found | |
| AimMarker | AimMarkerPrefab |
| An AimMarker prefab to use to show where this auto aim weapon is aiming. | |
| bool | DestroyAimMarkerOnWeaponDestroy = true |
| if this is true, the aim marker will be removed when the weapon gets destroyed | |
| MMFeedbacks | FirstTargetFoundFeedback |
| A feedback to play when a target is found and we didn't have one already. | |
| MMFeedbacks | NewTargetFoundFeedback |
| a feedback to play when we already had a target and just found a new one | |
| MMFeedbacks | NoMoreTargetsFeedback |
| a feedback to play when no more targets are found, and we just lost our last target | |
| Transform | Target |
| the current target of the auto aim module | |
| bool | DrawDebugRadius = true |
| whether or not to draw a debug sphere around the weapon to show its aim radius | |
Protected Member Functions | |
| override void | Initialization () |
| On init we grab our orientation to be able to detect facing direction. | |
| override bool | ScanForTargets () |
| Scans for targets by performing an overlap detection, then verifying line of fire with a boxcast. | |
| override void | SetAim () |
| Sets the aim to the relative direction of the target. | |
| override void | DetermineRaycastOrigin () |
| To determine our raycast origin we apply an offset. | |
| Protected Member Functions inherited from MoreMountains.TopDownEngine.WeaponAutoAim | |
| virtual void | Start () |
| On Awake we initialize our component. | |
| virtual void | Update () |
| On Update, we setup our ray origin, scan periodically and set aim if needed. | |
| void | DetermineRaycastOrigin () |
| A method used to compute the origin of the detection casts. | |
| bool | ScanForTargets () |
| This method should define how the scan for targets is performed. | |
| void | SetAim () |
| Sends aim coordinates to the weapon aim component. | |
| virtual void | HandleTargetChange () |
| Checks for target changes and triggers the appropriate methods if needed. | |
| virtual void | NoMoreTargets () |
| When no more targets are found, and we just lost one, we play a dedicated feedback. | |
| virtual void | FirstTargetFound () |
| When a new target is found and we didn't have one already, we play a dedicated feedback. | |
| virtual void | NewTargetFound () |
| When a new target is found, and we previously had another, we play a dedicated feedback. | |
| virtual void | HandleMoveCameraTarget () |
| Moves the camera target if needed. | |
| virtual void | ScanIfNeeded () |
| Performs a periodic scan. | |
| virtual void | HandleTarget () |
| Sets aim if needed, otherwise reverts to the previous aim control mode. | |
| virtual void | OnDrawGizmos () |
| Draws a sphere around the weapon to show its auto aim radius. | |
| virtual void | OnDisable () |
| On Disable, we hide our aim marker if needed. | |
| void | OnDestroy () |
Protected Attributes | |
| CharacterOrientation2D | _orientation2D |
| Vector2 | _facingDirection |
| Vector3 | _boxcastDirection |
| Vector3 | _aimDirection |
| bool | _initialized = false |
| List< Transform > | _potentialTargets |
| Collider2D[] | _results |
| RaycastHit2D | _hit |
| Protected Attributes inherited from MoreMountains.TopDownEngine.WeaponAutoAim | |
| float | _lastScanTimestamp = 0f |
| WeaponAim | _weaponAim |
| WeaponAim.AimControls | _originalAimControl |
| WeaponAim.RotationModes | _originalRotationMode |
| Vector3 | _raycastOrigin |
| Weapon | _weapon |
| bool | _originalMoveCameraTarget |
| Transform | _targetLastFrame |
| AimMarker | _aimMarker |
| Vector3 | _newCamTargetPosition |
| Moves the camera target towards the auto aim target if needed. | |
| Vector3 | _newCamTargetDirection |
| bool | _isOwnerNull |
Additional Inherited Members | |
| Public Member Functions inherited from MoreMountains.TopDownEngine.WeaponAutoAim | |
| virtual bool | CanAcquireNewTargets () |
The 2D version of the WeaponAutoAim, meant to be used on objects equipped with a WeaponAim2D. It'll detect targets within the defined radius, pick the closest, and force the WeaponAim component to aim at them if a target is found.
|
protected |
To determine our raycast origin we apply an offset.
|
protectedvirtual |
On init we grab our orientation to be able to detect facing direction.
Reimplemented from MoreMountains.TopDownEngine.WeaponAutoAim.
|
protected |
Scans for targets by performing an overlap detection, then verifying line of fire with a boxcast.
|
protected |
Sets the aim to the relative direction of the target.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
| int MoreMountains.TopDownEngine.WeaponAutoAim2D.OverlapMaximum = 10 |
the maximum amount of targets the overlap detection can acquire