TopDown Engine v4.5
Loading...
Searching...
No Matches
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
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

virtual void Start ()
 On Awake we initialize our component.
virtual void Initialization ()
 On init we grab our WeaponAim.
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

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

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()

void MoreMountains.TopDownEngine.WeaponAutoAim.DetermineRaycastOrigin ( )
abstractprotected

A method used to compute the origin of the detection casts.

◆ 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()

bool MoreMountains.TopDownEngine.WeaponAutoAim.ScanForTargets ( )
abstractprotected

This method should define how the scan for targets is performed.

Returns

◆ ScanIfNeeded()

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

Performs a periodic scan.

◆ SetAim()

void MoreMountains.TopDownEngine.WeaponAutoAim.SetAim ( )
abstractprotected

Sends aim coordinates to the weapon aim component.

◆ 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:
  • H:/Code/MoreMountains/topdownengine/Assets/TopDownEngine/Common/Scripts/Characters/Weapons/WeaponAutoAim.cs