Corgi Engine v9.4
Loading...
Searching...
No Matches
MoreMountains.CorgiEngine.BouncyProjectile Class Reference

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

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

Public Member Functions

virtual void OnTriggerEnter2D (Collider2D collider)
 On trigger enter 2D, we call our colliding endpoint.
virtual void PreventedCollision2D (RaycastHit2D hit)
 If we get a prevent collision 2D message, we check if we should bounce.
Public Member Functions inherited from MoreMountains.CorgiEngine.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 Flip ()
 Flip the projectile.
virtual void SetWeapon (Weapon newWeapon)
 Sets the projectile's parent weapon.
virtual void SetOwner (GameObject newOwner)
 Sets the projectile's owner.
virtual GameObject GetOwner ()
 Returns the current Owner of the projectile.
virtual void SetDamage (int newDamage)
 Sets the damage caused by the projectile's DamageOnTouch to the specified value.
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.

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
 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)
Public Attributes inherited from MoreMountains.CorgiEngine.Projectile
bool FaceDirection = true
 if true, the projectile will rotate at initialization towards its rotation
bool FaceMovementDirection = false
 if this is true, the projectile will update its rotation every frame to match its movement direction
float Speed = 200
 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 - this will only be taken into account if this projectile's game object doesn't have a SpriteRenderer component. If it does, the flipX property of the SpriteRenderer will be used instead.
bool ProjectileIsFacingRight = true
 determines whether or not the projectile is facing right
float InitialInvulnerabilityDuration =0f
 the initial delay during which the projectile can't be destroyed
bool DamageOwner = false
 should the projectile damage its owner ?
bool SpawnSecurityCheck = false
 if this is true, the projectile will perform an extra check on initialization to make sure it's not within an obstacle. If it is, it'll disable itself.
LayerMask SpawnSecurityCheckLayerMask
 the layermask to use when performing the security check
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 Initialization ()
 On init we randomize our values, refresh our 2D collider because Unity is weird sometimes.
virtual void Colliding (GameObject collider)
 Colliding endpoint.
virtual void EvaluateHit (RaycastHit2D hit)
 Decides whether or not we should bounce.
virtual void Bounce (RaycastHit2D hit)
 Applies a bounce in 2D.
virtual void LateUpdate ()
 On late update we store our position.
Protected Member Functions inherited from MoreMountains.CorgiEngine.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 CheckForCollider ()
 Performs a local check to see if the projectile is within a collider or not.
virtual void FixedUpdate ()
 On FixedUpdate(), we move the object based on the level's speed and the object's speed, and apply acceleration.
virtual void HandleFaceMovement ()
 If FaceMovementDirection is true, orients the projectile to match its current movement direction.
virtual void OnHit ()
 On hit, we trigger a hit on our owner weapon.
virtual void OnHitDamageable ()
 On hit damageable, we trigger a hit damageable on our owner weapon.
virtual void OnHitNonDamageable ()
 On hit non damageable, we trigger a hit non damageable on our owner weapon.
virtual void OnKill ()
 On kill, we trigger a kill on our owner weapon.
override void OnEnable ()
 On enable, we reset the object's speed.
override void OnDisable ()
 On disable, we unsubscribe from our delegates.
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

Vector3 _positionLastFrame
Vector3 _raycastDirection
Vector3 _reflectedDirection
int _randomAmountOfBounces
int _bouncesLeft
float _randomSpeedModifier
Protected Attributes inherited from MoreMountains.CorgiEngine.Projectile
Weapon _weapon
GameObject _owner
Vector3 _movement
float _initialSpeed
SpriteRenderer _spriteRenderer
DamageOnTouch _damageOnTouch
WaitForSeconds _initialInvulnerabilityDurationWFS
BoxCollider2D _collider
Vector2 _raycastOrigin
bool _facingRightInitially
bool _initialFlipX
Vector3 _initialLocalScale
RaycastHit2D _hit2D
Health _health
bool _spawnerIsFacingRight

Additional Inherited Members

Public Types inherited from MoreMountains.Tools.MMObjectBounds
enum  WaysToDetermineBounds { Collider , Collider2D , Renderer , Undefined }
Static Protected Attributes inherited from MoreMountains.CorgiEngine.Projectile
const float _raycastSkinSecurity =0.01f
Properties inherited from MoreMountains.CorgiEngine.Projectile
virtual DamageOnTouch TargetDamageOnTouch [get]
 Returns the associated damage on touch zone.
virtual Weapon SourceWeapon [get]
 Returns the weapon that created this projectile, if there's one.
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

◆ Bounce()

virtual void MoreMountains.CorgiEngine.BouncyProjectile.Bounce ( RaycastHit2D hit)
protectedvirtual

Applies a bounce in 2D.

Parameters
hit

◆ Colliding()

virtual void MoreMountains.CorgiEngine.BouncyProjectile.Colliding ( GameObject collider)
protectedvirtual

Colliding endpoint.

Parameters
collider

◆ EvaluateHit()

virtual void MoreMountains.CorgiEngine.BouncyProjectile.EvaluateHit ( RaycastHit2D hit)
protectedvirtual

Decides whether or not we should bounce.

◆ Initialization()

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

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

Reimplemented from MoreMountains.CorgiEngine.Projectile.

◆ LateUpdate()

virtual void MoreMountains.CorgiEngine.BouncyProjectile.LateUpdate ( )
protectedvirtual

On late update we store our position.

◆ OnTriggerEnter2D()

virtual void MoreMountains.CorgiEngine.BouncyProjectile.OnTriggerEnter2D ( Collider2D collider)
virtual

On trigger enter 2D, we call our colliding endpoint.

Parameters
collider

S

◆ PreventedCollision2D()

virtual void MoreMountains.CorgiEngine.BouncyProjectile.PreventedCollision2D ( RaycastHit2D hit)
virtual

If we get a prevent collision 2D message, we check if we should bounce.

Parameters
hit

Member Data Documentation

◆ _bouncesLeft

int MoreMountains.CorgiEngine.BouncyProjectile._bouncesLeft
protected

◆ _positionLastFrame

Vector3 MoreMountains.CorgiEngine.BouncyProjectile._positionLastFrame
protected

◆ _randomAmountOfBounces

int MoreMountains.CorgiEngine.BouncyProjectile._randomAmountOfBounces
protected

◆ _randomSpeedModifier

float MoreMountains.CorgiEngine.BouncyProjectile._randomSpeedModifier
protected

◆ _raycastDirection

Vector3 MoreMountains.CorgiEngine.BouncyProjectile._raycastDirection
protected

◆ _reflectedDirection

Vector3 MoreMountains.CorgiEngine.BouncyProjectile._reflectedDirection
protected

◆ AmountOfBounces

Vector2Int MoreMountains.CorgiEngine.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.CorgiEngine.BouncyProjectile.BounceFeedback

a feedback to trigger at every bounce

◆ BounceLayers

LayerMask MoreMountains.CorgiEngine.BouncyProjectile.BounceLayers

the layers you want this projectile to bounce on

◆ BounceRaycastLength

float MoreMountains.CorgiEngine.BouncyProjectile.BounceRaycastLength = 1f

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

◆ SpeedModifier

Vector2 MoreMountains.CorgiEngine.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)


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