Feel  3.16
The best way to improve your game's feel and make it extra juicy
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 Types

enum  Modes { Modes.Raycast, Modes.BoxCast }
 

Public Attributes

Modes Mode = Modes.Raycast
 whether to cast a ray or a boxcast to look for targets More...
 
LayerMask ObstaclesLayerMask
 the layer mask to search obstacles on More...
 
float SkinWidth = 0.1f
 the bounds adjustment variable More...
 
bool RepositionRigidbodyIfHitTrigger = true
 whether or not to reposition the rb if hitting a trigger collider More...
 
bool RepositionRigidbodyIfHitNonTrigger = true
 whether or not to reposition the rb if hitting a non trigger collider More...
 
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
 
RaycastHit2D _hitInfo
 
Vector2 _colliderSize
 

Detailed Description

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

Member Enumeration Documentation

◆ Modes

Enumerator
Raycast 
BoxCast 

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

◆ _colliderSize

Vector2 MoreMountains.Tools.MMPreventPassingThrough2D._colliderSize
protected

◆ _hitInfo

RaycastHit2D MoreMountains.Tools.MMPreventPassingThrough2D._hitInfo
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

◆ Mode

Modes MoreMountains.Tools.MMPreventPassingThrough2D.Mode = Modes.Raycast

whether to cast a ray or a boxcast to look for targets

◆ ObstaclesLayerMask

LayerMask MoreMountains.Tools.MMPreventPassingThrough2D.ObstaclesLayerMask

the layer mask to search obstacles on

◆ RepositionRigidbodyIfHitNonTrigger

bool MoreMountains.Tools.MMPreventPassingThrough2D.RepositionRigidbodyIfHitNonTrigger = true

whether or not to reposition the rb if hitting a non trigger collider

◆ RepositionRigidbodyIfHitTrigger

bool MoreMountains.Tools.MMPreventPassingThrough2D.RepositionRigidbodyIfHitTrigger = true

whether or not to reposition the rb if hitting a trigger collider

◆ SkinWidth

float MoreMountains.Tools.MMPreventPassingThrough2D.SkinWidth = 0.1f

the bounds adjustment variable


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