TopDown Engine  v3.6
MoreMountains.TopDownEngine.WeaponPreventShootingWhenCloseToWalls2D Class Reference

Add this class to a weapon and it'll prevent shooting when close to an obstacle (as defined by the ObstacleLayerMask) More...

Inheritance diagram for MoreMountains.TopDownEngine.WeaponPreventShootingWhenCloseToWalls2D:
MoreMountains.TopDownEngine.WeaponPreventShooting MoreMountains.TopDownEngine.TopDownMonoBehaviour MoreMountains.Tools.MMMonoBehaviour

Public Member Functions

override bool ShootingAllowed ()
 Shooting is allowed if no obstacle is in front of the weapon More...
 

Public Attributes

float Angle = 5f
 the angle to consider when deciding whether or not there's a wall in front of the weapon (usually 5 degrees is fine) More...
 
float Distance = 2f
 the max distance to the wall we want to prevent shooting from More...
 
Vector3 RaycastOriginOffset = Vector3.zero
 the offset to apply to the detection (in addition and relative to the weapon's position) More...
 
LayerMask ObstacleLayerMask = LayerManager.ObstaclesLayerMask
 the layers to consider as obstacles More...
 

Protected Member Functions

virtual void Awake ()
 On Awake we grab our weapon More...
 
virtual bool CheckForObstacles ()
 Casts rays in front of the weapon to check for obstacles Returns true if an obstacle was found More...
 

Protected Attributes

RaycastHit2D _hitLeft
 
RaycastHit2D _hitMiddle
 
RaycastHit2D _hitRight
 
WeaponAim _weaponAim
 

Detailed Description

Add this class to a weapon and it'll prevent shooting when close to an obstacle (as defined by the ObstacleLayerMask)

Member Function Documentation

◆ Awake()

virtual void MoreMountains.TopDownEngine.WeaponPreventShootingWhenCloseToWalls2D.Awake ( )
protectedvirtual

On Awake we grab our weapon

◆ CheckForObstacles()

virtual bool MoreMountains.TopDownEngine.WeaponPreventShootingWhenCloseToWalls2D.CheckForObstacles ( )
protectedvirtual

Casts rays in front of the weapon to check for obstacles Returns true if an obstacle was found

Returns

◆ ShootingAllowed()

override bool MoreMountains.TopDownEngine.WeaponPreventShootingWhenCloseToWalls2D.ShootingAllowed ( )
virtual

Shooting is allowed if no obstacle is in front of the weapon

Returns

Implements MoreMountains.TopDownEngine.WeaponPreventShooting.

Member Data Documentation

◆ _hitLeft

RaycastHit2D MoreMountains.TopDownEngine.WeaponPreventShootingWhenCloseToWalls2D._hitLeft
protected

◆ _hitMiddle

RaycastHit2D MoreMountains.TopDownEngine.WeaponPreventShootingWhenCloseToWalls2D._hitMiddle
protected

◆ _hitRight

RaycastHit2D MoreMountains.TopDownEngine.WeaponPreventShootingWhenCloseToWalls2D._hitRight
protected

◆ _weaponAim

WeaponAim MoreMountains.TopDownEngine.WeaponPreventShootingWhenCloseToWalls2D._weaponAim
protected

◆ Angle

float MoreMountains.TopDownEngine.WeaponPreventShootingWhenCloseToWalls2D.Angle = 5f

the angle to consider when deciding whether or not there's a wall in front of the weapon (usually 5 degrees is fine)

◆ Distance

float MoreMountains.TopDownEngine.WeaponPreventShootingWhenCloseToWalls2D.Distance = 2f

the max distance to the wall we want to prevent shooting from

◆ ObstacleLayerMask

LayerMask MoreMountains.TopDownEngine.WeaponPreventShootingWhenCloseToWalls2D.ObstacleLayerMask = LayerManager.ObstaclesLayerMask

the layers to consider as obstacles

◆ RaycastOriginOffset

Vector3 MoreMountains.TopDownEngine.WeaponPreventShootingWhenCloseToWalls2D.RaycastOriginOffset = Vector3.zero

the offset to apply to the detection (in addition and relative to the weapon's position)


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