Highroad Engine v1.3
Public Attributes | Protected Member Functions | Protected Attributes | List of all members
MoreMountains.Tools.MMPreventPassingThrough2D Class Reference

Prevents fast moving objects from going through colliders by casting a ray backwards after each movement More...

Inheritance diagram for MoreMountains.Tools.MMPreventPassingThrough2D:

Public Attributes

LayerMask ObstaclesLayerMask
 the layer mask to search obstacles on More...
 
float SkinWidth = 0.1f
 the bounds adjustment variable More...
 
bool RepositionRigidbody = true
 
RaycastHit2D Hit
 

Protected Member Functions

virtual void Start ()
 On Start we initialize our object More...
 
virtual void Initialization ()
 Grabs the rigidbody and computes the bounds width More...
 
virtual void OnEnable ()
 On Enable, we initialize our last frame position More...
 
virtual void Update ()
 On fixedUpdate, checks the last movement and if needed casts a ray to detect obstacles More...
 

Protected Attributes

float _smallestBoundsWidth
 
float _adjustedSmallestBoundsWidth
 
float _squaredBoundsWidth
 
Vector3 _positionLastFrame
 
Rigidbody2D _rigidbody
 
Collider2D _collider
 
Vector2 _lastMovement
 
float _lastMovementSquared
 

Detailed Description

Prevents fast moving objects from going through colliders by casting a ray backwards after each movement

Member Function Documentation

◆ Initialization()

virtual void MoreMountains.Tools.MMPreventPassingThrough2D.Initialization ( )
protectedvirtual

Grabs the rigidbody and computes the bounds width

◆ OnEnable()

virtual void MoreMountains.Tools.MMPreventPassingThrough2D.OnEnable ( )
protectedvirtual

On Enable, we initialize our last frame position

◆ Start()

virtual void MoreMountains.Tools.MMPreventPassingThrough2D.Start ( )
protectedvirtual

On Start we initialize our object

◆ Update()

virtual void MoreMountains.Tools.MMPreventPassingThrough2D.Update ( )
protectedvirtual

On fixedUpdate, checks the last movement and if needed casts a ray to detect obstacles

Member Data Documentation

◆ _adjustedSmallestBoundsWidth

float MoreMountains.Tools.MMPreventPassingThrough2D._adjustedSmallestBoundsWidth
protected

◆ _collider

Collider2D MoreMountains.Tools.MMPreventPassingThrough2D._collider
protected

◆ _lastMovement

Vector2 MoreMountains.Tools.MMPreventPassingThrough2D._lastMovement
protected

◆ _lastMovementSquared

float MoreMountains.Tools.MMPreventPassingThrough2D._lastMovementSquared
protected

◆ _positionLastFrame

Vector3 MoreMountains.Tools.MMPreventPassingThrough2D._positionLastFrame
protected

◆ _rigidbody

Rigidbody2D MoreMountains.Tools.MMPreventPassingThrough2D._rigidbody
protected

◆ _smallestBoundsWidth

float MoreMountains.Tools.MMPreventPassingThrough2D._smallestBoundsWidth
protected

◆ _squaredBoundsWidth

float MoreMountains.Tools.MMPreventPassingThrough2D._squaredBoundsWidth
protected

◆ Hit

RaycastHit2D MoreMountains.Tools.MMPreventPassingThrough2D.Hit

◆ ObstaclesLayerMask

LayerMask MoreMountains.Tools.MMPreventPassingThrough2D.ObstaclesLayerMask

the layer mask to search obstacles on

◆ RepositionRigidbody

bool MoreMountains.Tools.MMPreventPassingThrough2D.RepositionRigidbody = true

◆ SkinWidth

float MoreMountains.Tools.MMPreventPassingThrough2D.SkinWidth = 0.1f

the bounds adjustment variable


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