TopDown Engine v4.5
Loading...
Searching...
No Matches
MoreMountains.TopDownEngine.BouncyProjectile Class Reference

Projectile class that will bounce off walls instead of exploding on impact. More...

Inheritance diagram for MoreMountains.TopDownEngine.BouncyProjectile:
MoreMountains.TopDownEngine.Projectile MoreMountains.Tools.MMPoolableObject MoreMountains.Tools.MMObjectBounds

Public Attributes

float BounceRaycastLength = 1f
 the length of the raycast used to detect bounces, should be proportionate to the size and speed of your projectile
LayerMask BounceLayers = LayerManager.ObstaclesLayerMask
 the layers you want this projectile to bounce on
MMFeedbacks BounceFeedback
 a feedback to trigger at every bounce
Vector2Int AmountOfBounces = new Vector2Int(10,10)
 the min and max amount of bounces (a value will be picked at random between both bounds)
Vector2 SpeedModifier = Vector2.one
 the min and max speed multiplier to apply at every bounce (a value will be picked at random between both bounds)
float MinimumBounceAngle = 10f
 the minimum angle at which the projectile can bounce off the walls, tweak this if you'd like to avoid bounces at too low angles
Public Attributes inherited from MoreMountains.TopDownEngine.Projectile
bool FaceDirection = true
 if true, the projectile will rotate at initialization towards its rotation
bool FaceMovement = false
 if true, the projectile will rotate towards movement
MovementVectors MovementVector = MovementVectors.Forward
 if FaceMovement is true, the projectile's vector specified below will be aligned to the movement vector, usually you'll want to go with Forward in 3D, Right in 2D
float Speed = 0
 the speed of the object (relative to the level's speed)
float Acceleration = 0
 the acceleration of the object over time. Starts accelerating on enable.
Vector3 Direction = Vector3.left
 the current direction of the object
bool DirectionCanBeChangedBySpawner = true
 if set to true, the spawner can change the direction of the object. If not the one set in its inspector will be used.
Vector3 FlipValue = new Vector3(-1,1,1)
 the flip factor to apply if and when the projectile is mirrored
bool ProjectileIsFacingRight = true
 set this to true if your projectile's model (or sprite) is facing right, false otherwise
float InitialInvulnerabilityDuration =0f
 the initial delay during which the projectile can't be destroyed
bool DamageOwner = false
 should the projectile damage its owner?
Public Attributes inherited from MoreMountains.Tools.MMPoolableObject
UnityEvent ExecuteOnEnable
UnityEvent ExecuteOnDisable
float LifeTime = 0f
 The life time, in seconds, of the object. If set to 0 it'll live forever, if set to any positive value it'll be set inactive after that time.
Public Attributes inherited from MoreMountains.Tools.MMObjectBounds
WaysToDetermineBounds BoundsBasedOn

Protected Member Functions

override void OnEnable ()
 When the objects get enabled (usually after having been pooled from an ObjectPooler, we initiate its death countdown.
override void Initialization ()
 On init we randomize our values, refresh our 2D collider because Unity is weird sometimes.
override void FixedUpdate ()
 On update(), we move the object based on the level's speed and the object's speed, and apply acceleration.
virtual void SetPositionLastFrame ()
virtual void EvaluateHit3D (RaycastHit hit)
 Decides whether or not we should bounce.
virtual void EvaluateHit2D (RaycastHit2D hit)
 Decides whether or not we should bounce.
virtual void Bounce2D (RaycastHit2D hit)
 Applies a bounce in 2D.
virtual void Bounce3D (RaycastHit hit)
 Applies a bounce in 3D.
Protected Member Functions inherited from MoreMountains.TopDownEngine.Projectile
virtual void Awake ()
 On awake, we store the initial speed of the object.
virtual IEnumerator InitialInvulnerability ()
 Handles the projectile's initial invincibility.
virtual void Flip ()
 Flip the projectile.
virtual void Flip (bool state)
 Flip the projectile.
virtual void OnDeath ()
 On death, we stop our projectile.
override void OnEnable ()
 On enable, we trigger a short invulnerability.
override void OnDisable ()
 On disable, we plug our OnDeath method to the health component.
Protected Member Functions inherited from MoreMountains.Tools.MMPoolableObject
virtual void Update ()
 Called every frame.
Protected Member Functions inherited from MoreMountains.Tools.MMObjectBounds
virtual void Reset ()
 When this component is added we define its bounds.
virtual void DefineBoundsChoice ()
 Tries to determine automatically what the bounds should be based on. In this order, it'll keep the last found of these : Collider2D, Collider or Renderer. If none of these is found, it'll be set as Undefined.

Protected Attributes

Rigidbody _rigidbody
Rigidbody2D _rigidbody2D
Vector3 _positionLastFrame
Vector3 _raycastDirection
Vector3 _reflectedDirection
int _randomAmountOfBounces
int _bouncesLeft
float _randomSpeedModifier
Protected Attributes inherited from MoreMountains.TopDownEngine.Projectile
Weapon _weapon
GameObject _owner
Vector3 _movement
float _initialSpeed
SpriteRenderer _spriteRenderer
DamageOnTouch _damageOnTouch
WaitForSeconds _initialInvulnerabilityDurationWFS
Collider _collider
Collider2D _collider2D
Rigidbody _rigidBody
Rigidbody2D _rigidBody2D
bool _facingRightInitially
bool _initialFlipX
Vector3 _initialLocalScale
bool _shouldMove = true
Health _health
bool _spawnerIsFacingRight

Static Protected Attributes

const float WALL_AVOIDANCE_DISTANCE = 0.001f

Additional Inherited Members

Public Types inherited from MoreMountains.TopDownEngine.Projectile
enum  MovementVectors { Forward , Right , Up }
Public Types inherited from MoreMountains.Tools.MMObjectBounds
enum  WaysToDetermineBounds { Collider , Collider2D , Renderer , Undefined }
Public Member Functions inherited from MoreMountains.TopDownEngine.Projectile
virtual void Movement ()
 Handles the projectile's movement, every frame.
virtual void SetDirection (Vector3 newDirection, Quaternion newRotation, bool spawnerIsFacingRight=true)
 Sets the projectile's direction.
virtual void SetWeapon (Weapon newWeapon)
 Sets the projectile's parent weapon.
virtual void SetDamage (float minDamage, float maxDamage)
 Sets the damage caused by the projectile's DamageOnTouch to the specified value.
virtual void SetOwner (GameObject newOwner)
 Sets the projectile's owner.
virtual GameObject GetOwner ()
 Returns the current Owner of the projectile.
virtual void StopAt ()
 On death, disables colliders and prevents movement.
Public Member Functions inherited from MoreMountains.Tools.MMPoolableObject
delegate void Events ()
virtual void Destroy ()
 Turns the instance inactive, in order to eventually reuse it.
virtual void TriggerOnSpawnComplete ()
 Triggers the on spawn complete event.
Public Member Functions inherited from MoreMountains.Tools.MMObjectBounds
virtual Bounds GetBounds ()
 Returns the bounds of the object, based on what has been defined.
Properties inherited from MoreMountains.TopDownEngine.Projectile
virtual DamageOnTouch TargetDamageOnTouch [get]
 Returns the associated damage on touch zone.
virtual Weapon SourceWeapon [get]
Properties inherited from MoreMountains.Tools.MMObjectBounds
virtual Vector3 Size [get, set]
Events inherited from MoreMountains.Tools.MMPoolableObject
Events OnSpawnComplete

Detailed Description

Projectile class that will bounce off walls instead of exploding on impact.

Member Function Documentation

◆ Bounce2D()

virtual void MoreMountains.TopDownEngine.BouncyProjectile.Bounce2D ( RaycastHit2D hit)
protectedvirtual

Applies a bounce in 2D.

Parameters
hit

◆ Bounce3D()

virtual void MoreMountains.TopDownEngine.BouncyProjectile.Bounce3D ( RaycastHit hit)
protectedvirtual

Applies a bounce in 3D.

Parameters
hit

◆ EvaluateHit2D()

virtual void MoreMountains.TopDownEngine.BouncyProjectile.EvaluateHit2D ( RaycastHit2D hit)
protectedvirtual

Decides whether or not we should bounce.

◆ EvaluateHit3D()

virtual void MoreMountains.TopDownEngine.BouncyProjectile.EvaluateHit3D ( RaycastHit hit)
protectedvirtual

Decides whether or not we should bounce.

Parameters
hit

◆ FixedUpdate()

override void MoreMountains.TopDownEngine.BouncyProjectile.FixedUpdate ( )
protectedvirtual

On update(), we move the object based on the level's speed and the object's speed, and apply acceleration.

Reimplemented from MoreMountains.TopDownEngine.Projectile.

◆ Initialization()

override void MoreMountains.TopDownEngine.BouncyProjectile.Initialization ( )
protectedvirtual

On init we randomize our values, refresh our 2D collider because Unity is weird sometimes.

Reimplemented from MoreMountains.TopDownEngine.Projectile.

◆ OnEnable()

override void MoreMountains.TopDownEngine.BouncyProjectile.OnEnable ( )
protectedvirtual

When the objects get enabled (usually after having been pooled from an ObjectPooler, we initiate its death countdown.

Reimplemented from MoreMountains.Tools.MMPoolableObject.

◆ SetPositionLastFrame()

virtual void MoreMountains.TopDownEngine.BouncyProjectile.SetPositionLastFrame ( )
protectedvirtual

Member Data Documentation

◆ _bouncesLeft

int MoreMountains.TopDownEngine.BouncyProjectile._bouncesLeft
protected

◆ _positionLastFrame

Vector3 MoreMountains.TopDownEngine.BouncyProjectile._positionLastFrame
protected

◆ _randomAmountOfBounces

int MoreMountains.TopDownEngine.BouncyProjectile._randomAmountOfBounces
protected

◆ _randomSpeedModifier

float MoreMountains.TopDownEngine.BouncyProjectile._randomSpeedModifier
protected

◆ _raycastDirection

Vector3 MoreMountains.TopDownEngine.BouncyProjectile._raycastDirection
protected

◆ _reflectedDirection

Vector3 MoreMountains.TopDownEngine.BouncyProjectile._reflectedDirection
protected

◆ _rigidbody

Rigidbody MoreMountains.TopDownEngine.BouncyProjectile._rigidbody
protected

◆ _rigidbody2D

Rigidbody2D MoreMountains.TopDownEngine.BouncyProjectile._rigidbody2D
protected

◆ AmountOfBounces

Vector2Int MoreMountains.TopDownEngine.BouncyProjectile.AmountOfBounces = new Vector2Int(10,10)

the min and max amount of bounces (a value will be picked at random between both bounds)

◆ BounceFeedback

MMFeedbacks MoreMountains.TopDownEngine.BouncyProjectile.BounceFeedback

a feedback to trigger at every bounce

◆ BounceLayers

LayerMask MoreMountains.TopDownEngine.BouncyProjectile.BounceLayers = LayerManager.ObstaclesLayerMask

the layers you want this projectile to bounce on

◆ BounceRaycastLength

float MoreMountains.TopDownEngine.BouncyProjectile.BounceRaycastLength = 1f

the length of the raycast used to detect bounces, should be proportionate to the size and speed of your projectile

◆ MinimumBounceAngle

float MoreMountains.TopDownEngine.BouncyProjectile.MinimumBounceAngle = 10f

the minimum angle at which the projectile can bounce off the walls, tweak this if you'd like to avoid bounces at too low angles

◆ SpeedModifier

Vector2 MoreMountains.TopDownEngine.BouncyProjectile.SpeedModifier = Vector2.one

the min and max speed multiplier to apply at every bounce (a value will be picked at random between both bounds)

◆ WALL_AVOIDANCE_DISTANCE

const float MoreMountains.TopDownEngine.BouncyProjectile.WALL_AVOIDANCE_DISTANCE = 0.001f
staticprotected

The documentation for this class was generated from the following file:
  • H:/Code/MoreMountains/topdownengine/Assets/TopDownEngine/Common/Scripts/Characters/Weapons/BouncyProjectile.cs