TopDown Engine v4.5
Loading...
Searching...
No Matches
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.
Public Member Functions inherited from MoreMountains.TopDownEngine.WeaponPreventShooting
bool ShootingAllowed ()
 Override this method to define shooting conditions.

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)
float Distance = 2f
 the max distance to the wall we want to prevent shooting from
Vector3 RaycastOriginOffset = Vector3.zero
 the offset to apply to the detection (in addition and relative to the weapon's position)
LayerMask ObstacleLayerMask = LayerManager.ObstaclesLayerMask
 the layers to consider as obstacles

Protected Member Functions

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

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

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

Returns

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: