Feel 5.9.1
The best way to improve your game's feel and make it extra juicy
Loading...
Searching...
No Matches
MoreMountains.Tools.MMPreventPassingThrough3D Class Reference

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

Inheritance diagram for MoreMountains.Tools.MMPreventPassingThrough3D:

Public Types

enum  AdjustmentAxis { Auto , X , Y , Z }

Public Attributes

LayerMask ObstaclesLayerMask
 the layer mask to search obstacles on
float SkinWidth = 0.1f
 the bounds adjustment variable
bool RepositionRigidbody = true
LayerMask RepositionRigidbodyLayerMask
 the layer mask to filter when to reposition rigidbody
AdjustmentAxis Adjustment = AdjustmentAxis.Auto
 the local axis of the collider to use for adjustment (usually you'll want to use the axis the object is moving on)

Protected Member Functions

virtual void OnValidate ()
virtual void Start ()
 On Start we initialize our object.
virtual void Initialization ()
 Grabs the rigidbody and computes the bounds width.
virtual float ComputeAdjustmentDistance ()
 Determines the adjustment distance, over which we decide whether or not we've moved too far.
virtual void OnEnable ()
 On Enable, we initialize our last frame position.
virtual void FixedUpdate ()
 On fixedUpdate, checks the last movement and if needed casts a ray to detect obstacles.

Protected Attributes

float _adjustmentDistance
float _adjustedDistance
float _squaredBoundsWidth
Vector3 _positionLastFrame
Rigidbody _rigidbody
Collider _collider
Vector3 _lastMovement
float _lastMovementSquared

Detailed Description

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

Member Enumeration Documentation

◆ AdjustmentAxis

Member Function Documentation

◆ ComputeAdjustmentDistance()

virtual float MoreMountains.Tools.MMPreventPassingThrough3D.ComputeAdjustmentDistance ( )
protectedvirtual

Determines the adjustment distance, over which we decide whether or not we've moved too far.

Returns

◆ FixedUpdate()

virtual void MoreMountains.Tools.MMPreventPassingThrough3D.FixedUpdate ( )
protectedvirtual

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

◆ Initialization()

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

Grabs the rigidbody and computes the bounds width.

◆ OnEnable()

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

On Enable, we initialize our last frame position.

◆ OnValidate()

virtual void MoreMountains.Tools.MMPreventPassingThrough3D.OnValidate ( )
protectedvirtual

◆ Start()

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

On Start we initialize our object.

Member Data Documentation

◆ _adjustedDistance

float MoreMountains.Tools.MMPreventPassingThrough3D._adjustedDistance
protected

◆ _adjustmentDistance

float MoreMountains.Tools.MMPreventPassingThrough3D._adjustmentDistance
protected

◆ _collider

Collider MoreMountains.Tools.MMPreventPassingThrough3D._collider
protected

◆ _lastMovement

Vector3 MoreMountains.Tools.MMPreventPassingThrough3D._lastMovement
protected

◆ _lastMovementSquared

float MoreMountains.Tools.MMPreventPassingThrough3D._lastMovementSquared
protected

◆ _positionLastFrame

Vector3 MoreMountains.Tools.MMPreventPassingThrough3D._positionLastFrame
protected

◆ _rigidbody

Rigidbody MoreMountains.Tools.MMPreventPassingThrough3D._rigidbody
protected

◆ _squaredBoundsWidth

float MoreMountains.Tools.MMPreventPassingThrough3D._squaredBoundsWidth
protected

◆ Adjustment

AdjustmentAxis MoreMountains.Tools.MMPreventPassingThrough3D.Adjustment = AdjustmentAxis.Auto

the local axis of the collider to use for adjustment (usually you'll want to use the axis the object is moving on)

◆ ObstaclesLayerMask

LayerMask MoreMountains.Tools.MMPreventPassingThrough3D.ObstaclesLayerMask

the layer mask to search obstacles on

◆ RepositionRigidbody

bool MoreMountains.Tools.MMPreventPassingThrough3D.RepositionRigidbody = true

◆ RepositionRigidbodyLayerMask

LayerMask MoreMountains.Tools.MMPreventPassingThrough3D.RepositionRigidbodyLayerMask

the layer mask to filter when to reposition rigidbody

◆ SkinWidth

float MoreMountains.Tools.MMPreventPassingThrough3D.SkinWidth = 0.1f

the bounds adjustment variable


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