TopDown Engine  v3.6
MoreMountains.TopDownEngine.WeaponAutoAim Class Referenceabstract

An abstract class, meant to be extended for 2D and 3D specifics, handling the basics of auto aim. Extended components should be placed on a weapon with an aim component More...

Inheritance diagram for MoreMountains.TopDownEngine.WeaponAutoAim:
MoreMountains.TopDownEngine.TopDownMonoBehaviour MoreMountains.Tools.MMMonoBehaviour MoreMountains.TopDownEngine.WeaponAutoAim2D MoreMountains.TopDownEngine.WeaponAutoAim3D

Public Member Functions

virtual bool CanAcquireNewTargets ()
 

Public Attributes

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

virtual void Start ()
 On Awake we initialize our component More...
 
virtual void Initialization ()
 On init we grab our WeaponAim More...
 
virtual void Update ()
 On Update, we setup our ray origin, scan periodically and set aim if needed More...
 
abstract void DetermineRaycastOrigin ()
 A method used to compute the origin of the detection casts More...
 
abstract bool ScanForTargets ()
 This method should define how the scan for targets is performed More...
 
abstract void SetAim ()
 Sends aim coordinates to the weapon aim component 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

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
 

Detailed Description

An abstract class, meant to be extended for 2D and 3D specifics, handling the basics of auto aim. Extended components should be placed on a weapon with an aim component

Member Function Documentation

◆ CanAcquireNewTargets()

virtual bool MoreMountains.TopDownEngine.WeaponAutoAim.CanAcquireNewTargets ( )
virtual

Returns

◆ DetermineRaycastOrigin()

abstract void MoreMountains.TopDownEngine.WeaponAutoAim.DetermineRaycastOrigin ( )
protectedpure virtual

A method used to compute the origin of the detection casts

Implemented in MoreMountains.TopDownEngine.WeaponAutoAim3D, and MoreMountains.TopDownEngine.WeaponAutoAim2D.

◆ FirstTargetFound()

virtual void MoreMountains.TopDownEngine.WeaponAutoAim.FirstTargetFound ( )
protectedvirtual

When a new target is found and we didn't have one already, we play a dedicated feedback

◆ HandleMoveCameraTarget()

virtual void MoreMountains.TopDownEngine.WeaponAutoAim.HandleMoveCameraTarget ( )
protectedvirtual

Moves the camera target if needed

◆ HandleTarget()

virtual void MoreMountains.TopDownEngine.WeaponAutoAim.HandleTarget ( )
protectedvirtual

Sets aim if needed, otherwise reverts to the previous aim control mode

◆ HandleTargetChange()

virtual void MoreMountains.TopDownEngine.WeaponAutoAim.HandleTargetChange ( )
protectedvirtual

Checks for target changes and triggers the appropriate methods if needed

◆ Initialization()

virtual void MoreMountains.TopDownEngine.WeaponAutoAim.Initialization ( )
protectedvirtual

◆ NewTargetFound()

virtual void MoreMountains.TopDownEngine.WeaponAutoAim.NewTargetFound ( )
protectedvirtual

When a new target is found, and we previously had another, we play a dedicated feedback

◆ NoMoreTargets()

virtual void MoreMountains.TopDownEngine.WeaponAutoAim.NoMoreTargets ( )
protectedvirtual

When no more targets are found, and we just lost one, we play a dedicated feedback

◆ OnDestroy()

void MoreMountains.TopDownEngine.WeaponAutoAim.OnDestroy ( )
protected

◆ OnDisable()

virtual void MoreMountains.TopDownEngine.WeaponAutoAim.OnDisable ( )
protectedvirtual

On Disable, we hide our aim marker if needed

◆ OnDrawGizmos()

virtual void MoreMountains.TopDownEngine.WeaponAutoAim.OnDrawGizmos ( )
protectedvirtual

Draws a sphere around the weapon to show its auto aim radius

Reimplemented in MoreMountains.TopDownEngine.WeaponAutoAim3D.

◆ ScanForTargets()

abstract bool MoreMountains.TopDownEngine.WeaponAutoAim.ScanForTargets ( )
protectedpure virtual

This method should define how the scan for targets is performed

Returns

Implemented in MoreMountains.TopDownEngine.WeaponAutoAim3D, and MoreMountains.TopDownEngine.WeaponAutoAim2D.

◆ ScanIfNeeded()

virtual void MoreMountains.TopDownEngine.WeaponAutoAim.ScanIfNeeded ( )
protectedvirtual

Performs a periodic scan

◆ SetAim()

abstract void MoreMountains.TopDownEngine.WeaponAutoAim.SetAim ( )
protectedpure virtual

Sends aim coordinates to the weapon aim component

Implemented in MoreMountains.TopDownEngine.WeaponAutoAim3D, and MoreMountains.TopDownEngine.WeaponAutoAim2D.

◆ Start()

virtual void MoreMountains.TopDownEngine.WeaponAutoAim.Start ( )
protectedvirtual

On Awake we initialize our component

◆ Update()

virtual void MoreMountains.TopDownEngine.WeaponAutoAim.Update ( )
protectedvirtual

On Update, we setup our ray origin, scan periodically and set aim if needed

Member Data Documentation

◆ _aimMarker

AimMarker MoreMountains.TopDownEngine.WeaponAutoAim._aimMarker
protected

◆ _isOwnerNull

bool MoreMountains.TopDownEngine.WeaponAutoAim._isOwnerNull
protected

◆ _lastScanTimestamp

float MoreMountains.TopDownEngine.WeaponAutoAim._lastScanTimestamp = 0f
protected

◆ _newCamTargetDirection

Vector3 MoreMountains.TopDownEngine.WeaponAutoAim._newCamTargetDirection
protected

◆ _newCamTargetPosition

Vector3 MoreMountains.TopDownEngine.WeaponAutoAim._newCamTargetPosition
protected

Moves the camera target towards the auto aim target if needed

◆ _originalAimControl

WeaponAim.AimControls MoreMountains.TopDownEngine.WeaponAutoAim._originalAimControl
protected

◆ _originalMoveCameraTarget

bool MoreMountains.TopDownEngine.WeaponAutoAim._originalMoveCameraTarget
protected

◆ _originalRotationMode

WeaponAim.RotationModes MoreMountains.TopDownEngine.WeaponAutoAim._originalRotationMode
protected

◆ _raycastOrigin

Vector3 MoreMountains.TopDownEngine.WeaponAutoAim._raycastOrigin
protected

◆ _targetLastFrame

Transform MoreMountains.TopDownEngine.WeaponAutoAim._targetLastFrame
protected

◆ _weapon

Weapon MoreMountains.TopDownEngine.WeaponAutoAim._weapon
protected

◆ _weaponAim

WeaponAim MoreMountains.TopDownEngine.WeaponAutoAim._weaponAim
protected

◆ AimMarkerPrefab

AimMarker MoreMountains.TopDownEngine.WeaponAutoAim.AimMarkerPrefab

An AimMarker prefab to use to show where this auto aim weapon is aiming.

◆ ApplyAutoAimAsLastDirection

bool MoreMountains.TopDownEngine.WeaponAutoAim.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

◆ CameraTargetDistance

float MoreMountains.TopDownEngine.WeaponAutoAim.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)

◆ CameraTargetMaxDistance

float MoreMountains.TopDownEngine.WeaponAutoAim.CameraTargetMaxDistance = 10f

the maximum distance from the weapon owner at which the camera target can be

◆ CameraTargetSpeed

float MoreMountains.TopDownEngine.WeaponAutoAim.CameraTargetSpeed = 5f

the speed at which to move the camera target

◆ DestroyAimMarkerOnWeaponDestroy

bool MoreMountains.TopDownEngine.WeaponAutoAim.DestroyAimMarkerOnWeaponDestroy = true

if this is true, the aim marker will be removed when the weapon gets destroyed

◆ DetectionOriginOffset

Vector3 MoreMountains.TopDownEngine.WeaponAutoAim.DetectionOriginOffset = Vector3.zero

an offset to apply to the weapon's position for scan

◆ DrawDebugRadius

bool MoreMountains.TopDownEngine.WeaponAutoAim.DrawDebugRadius = true

whether or not to draw a debug sphere around the weapon to show its aim radius

◆ DurationBetweenScans

float MoreMountains.TopDownEngine.WeaponAutoAim.DurationBetweenScans = 1f

the duration (in seconds) between 2 scans for targets

◆ FirstTargetFoundFeedback

MMFeedbacks MoreMountains.TopDownEngine.WeaponAutoAim.FirstTargetFoundFeedback

A feedback to play when a target is found and we didn't have one already.

◆ LineOfFireBoxcastSize

Vector2 MoreMountains.TopDownEngine.WeaponAutoAim.LineOfFireBoxcastSize = new Vector2(0.1f, 0.1f)

the size of the boxcast that will be performed to verify line of fire

◆ MoveCameraTarget

bool MoreMountains.TopDownEngine.WeaponAutoAim.MoveCameraTarget = true

whether or not this component should take control of the camera target when a camera is found

◆ MoveCameraToCharacterIfNoTarget

bool MoreMountains.TopDownEngine.WeaponAutoAim.MoveCameraToCharacterIfNoTarget = false

if this is true, the camera target will move back to the character if no target is found

◆ NewTargetFoundFeedback

MMFeedbacks MoreMountains.TopDownEngine.WeaponAutoAim.NewTargetFoundFeedback

a feedback to play when we already had a target and just found a new one

◆ NoMoreTargetsFeedback

MMFeedbacks MoreMountains.TopDownEngine.WeaponAutoAim.NoMoreTargetsFeedback

a feedback to play when no more targets are found, and we just lost our last target

◆ ObstacleMask

LayerMask MoreMountains.TopDownEngine.WeaponAutoAim.ObstacleMask = LayerManager.ObstaclesLayerMask

the layermask on which to look for obstacles

◆ OnlyAcquireTargetsIfOwnerIsIdle

bool MoreMountains.TopDownEngine.WeaponAutoAim.OnlyAcquireTargetsIfOwnerIsIdle = false

if this is true, auto aim scan will only acquire new targets if the owner is in the idle state

◆ RotationMode

WeaponAim.RotationModes MoreMountains.TopDownEngine.WeaponAutoAim.RotationMode

the rotation mode to apply when a target is found

◆ ScanRadius

float MoreMountains.TopDownEngine.WeaponAutoAim.ScanRadius = 15f

the radius (in units) around the character within which to search for targets

◆ Target

Transform MoreMountains.TopDownEngine.WeaponAutoAim.Target

the current target of the auto aim module

◆ TargetsMask

LayerMask MoreMountains.TopDownEngine.WeaponAutoAim.TargetsMask

the layermask on which to look for aim targets


The documentation for this class was generated from the following file: