TopDown Engine
v3.6
|
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 More... | |
Public Attributes inherited from MoreMountains.TopDownEngine.WeaponAutoAim | |
LayerMask | TargetsMask |
the layermask on which to look for aim targets More... | |
LayerMask | ObstacleMask = LayerManager.ObstaclesLayerMask |
the layermask on which to look for obstacles More... | |
float | ScanRadius = 15f |
the radius (in units) around the character within which to search for targets More... | |
Vector2 | LineOfFireBoxcastSize = new Vector2(0.1f, 0.1f) |
the size of the boxcast that will be performed to verify line of fire More... | |
float | DurationBetweenScans = 1f |
the duration (in seconds) between 2 scans for targets More... | |
Vector3 | DetectionOriginOffset = Vector3.zero |
an offset to apply to the weapon's position for scan More... | |
bool | OnlyAcquireTargetsIfOwnerIsIdle = false |
if this is true, auto aim scan will only acquire new targets if the owner is in the idle state More... | |
WeaponAim.RotationModes | RotationMode |
the rotation mode to apply when a target is found More... | |
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 More... | |
bool | MoveCameraTarget = true |
whether or not this component should take control of the camera target when a camera is found More... | |
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) More... | |
float | CameraTargetMaxDistance = 10f |
the maximum distance from the weapon owner at which the camera target can be More... | |
float | CameraTargetSpeed = 5f |
the speed at which to move the camera target More... | |
bool | MoveCameraToCharacterIfNoTarget = false |
if this is true, the camera target will move back to the character if no target is found More... | |
AimMarker | AimMarkerPrefab |
An AimMarker prefab to use to show where this auto aim weapon is aiming. More... | |
bool | DestroyAimMarkerOnWeaponDestroy = true |
if this is true, the aim marker will be removed when the weapon gets destroyed More... | |
MMFeedbacks | FirstTargetFoundFeedback |
A feedback to play when a target is found and we didn't have one already. More... | |
MMFeedbacks | NewTargetFoundFeedback |
a feedback to play when we already had a target and just found a new one More... | |
MMFeedbacks | NoMoreTargetsFeedback |
a feedback to play when no more targets are found, and we just lost our last target More... | |
Transform | Target |
the current target of the auto aim module More... | |
bool | DrawDebugRadius = true |
whether or not to draw a debug sphere around the weapon to show its aim radius More... | |
Protected Member Functions | |
override void | Initialization () |
On init we grab our orientation to be able to detect facing direction More... | |
override bool | ScanForTargets () |
Scans for targets by performing an overlap detection, then verifying line of fire with a boxcast More... | |
override void | SetAim () |
Sets the aim to the relative direction of the target More... | |
override void | DetermineRaycastOrigin () |
To determine our raycast origin we apply an offset More... | |
Protected Member Functions inherited from MoreMountains.TopDownEngine.WeaponAutoAim | |
virtual void | Start () |
On Awake we initialize our component More... | |
virtual void | Update () |
On Update, we setup our ray origin, scan periodically and set aim if needed More... | |
virtual void | HandleTargetChange () |
Checks for target changes and triggers the appropriate methods if needed More... | |
virtual void | NoMoreTargets () |
When no more targets are found, and we just lost one, we play a dedicated feedback More... | |
virtual void | FirstTargetFound () |
When a new target is found and we didn't have one already, we play a dedicated feedback More... | |
virtual void | NewTargetFound () |
When a new target is found, and we previously had another, we play a dedicated feedback More... | |
virtual void | HandleMoveCameraTarget () |
Moves the camera target if needed More... | |
virtual void | ScanIfNeeded () |
Performs a periodic scan More... | |
virtual void | HandleTarget () |
Sets aim if needed, otherwise reverts to the previous aim control mode More... | |
virtual void | OnDrawGizmos () |
Draws a sphere around the weapon to show its auto aim radius More... | |
virtual void | OnDisable () |
On Disable, we hide our aim marker if needed More... | |
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 More... | |
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
|
protectedvirtual |
To determine our raycast origin we apply an offset
Implements MoreMountains.TopDownEngine.WeaponAutoAim.
|
protectedvirtual |
On init we grab our orientation to be able to detect facing direction
Reimplemented from MoreMountains.TopDownEngine.WeaponAutoAim.
|
protectedvirtual |
Scans for targets by performing an overlap detection, then verifying line of fire with a boxcast
Implements MoreMountains.TopDownEngine.WeaponAutoAim.
|
protectedvirtual |
Sets the aim to the relative direction of the target
Implements MoreMountains.TopDownEngine.WeaponAutoAim.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
int MoreMountains.TopDownEngine.WeaponAutoAim2D.OverlapMaximum = 10 |
the maximum amount of targets the overlap detection can acquire