![]() |
TopDown Engine v4.3
|
Projectile class that will bounce off walls instead of exploding on impact More...
Public Member Functions | |
virtual void | OnTriggerEnter2D (Collider2D collider) |
On trigger enter 2D, we call our colliding endpoint More... | |
virtual void | OnTriggerEnter (Collider collider) |
On trigger enter, we call our colliding endpoint More... | |
void | PreventedCollision2D (RaycastHit2D hit) |
If we get a prevent collision 2D message, we check if we should bounce More... | |
void | PreventedCollision3D (RaycastHit hit) |
If we get a prevent collision 3D message, we check if we should bounce More... | |
![]() | |
virtual void | Movement () |
Handles the projectile's movement, every frame More... | |
virtual void | SetDirection (Vector3 newDirection, Quaternion newRotation, bool spawnerIsFacingRight=true) |
Sets the projectile's direction. More... | |
virtual void | SetWeapon (Weapon newWeapon) |
Sets the projectile's parent weapon. More... | |
virtual void | SetDamage (float minDamage, float maxDamage) |
Sets the damage caused by the projectile's DamageOnTouch to the specified value More... | |
virtual void | SetOwner (GameObject newOwner) |
Sets the projectile's owner. More... | |
virtual GameObject | GetOwner () |
Returns the current Owner of the projectile More... | |
virtual void | StopAt () |
On death, disables colliders and prevents movement More... | |
![]() | |
delegate void | Events () |
virtual void | Destroy () |
Turns the instance inactive, in order to eventually reuse it. More... | |
virtual void | TriggerOnSpawnComplete () |
Triggers the on spawn complete event More... | |
![]() | |
virtual Bounds | GetBounds () |
Returns the bounds of the object, based on what has been defined More... | |
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 More... | |
LayerMask | BounceLayers = LayerManager.ObstaclesLayerMask |
the layers you want this projectile to bounce on More... | |
MMFeedbacks | BounceFeedback |
a feedback to trigger at every bounce More... | |
Vector2Int | AmountOfBounces = new Vector2Int(10,10) |
the min and max amount of bounces (a value will be picked at random between both bounds) More... | |
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) More... | |
![]() | |
bool | FaceDirection = true |
if true, the projectile will rotate at initialization towards its rotation More... | |
bool | FaceMovement = false |
if true, the projectile will rotate towards movement More... | |
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 More... | |
float | Speed = 0 |
the speed of the object (relative to the level's speed) More... | |
float | Acceleration = 0 |
the acceleration of the object over time. Starts accelerating on enable. More... | |
Vector3 | Direction = Vector3.left |
the current direction of the object More... | |
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. More... | |
Vector3 | FlipValue = new Vector3(-1,1,1) |
the flip factor to apply if and when the projectile is mirrored More... | |
bool | ProjectileIsFacingRight = true |
set this to true if your projectile's model (or sprite) is facing right, false otherwise More... | |
float | InitialInvulnerabilityDuration =0f |
the initial delay during which the projectile can't be destroyed More... | |
bool | DamageOwner = false |
should the projectile damage its owner? More... | |
![]() | |
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. More... | |
![]() | |
WaysToDetermineBounds | BoundsBasedOn |
Protected Member Functions | |
override void | Initialization () |
On init we randomize our values, refresh our 2D collider because Unity is weird sometimes More... | |
virtual void | Colliding (GameObject collider) |
Colliding endpoint More... | |
virtual void | EvaluateHit3D (RaycastHit hit) |
Decides whether or not we should bounce More... | |
virtual void | EvaluateHit2D (RaycastHit2D hit) |
Decides whether or not we should bounce More... | |
virtual void | Bounce2D (RaycastHit2D hit) |
Applies a bounce in 2D More... | |
virtual void | Bounce3D (RaycastHit hit) |
Applies a bounce in 3D More... | |
virtual void | LateUpdate () |
On late update we store our position More... | |
![]() | |
virtual void | Awake () |
On awake, we store the initial speed of the object More... | |
virtual IEnumerator | InitialInvulnerability () |
Handles the projectile's initial invincibility More... | |
virtual void | FixedUpdate () |
On update(), we move the object based on the level's speed and the object's speed, and apply acceleration More... | |
virtual void | Flip () |
Flip the projectile More... | |
virtual void | Flip (bool state) |
Flip the projectile More... | |
virtual void | OnDeath () |
On death, we stop our projectile More... | |
override void | OnEnable () |
On enable, we trigger a short invulnerability More... | |
override void | OnDisable () |
On disable, we plug our OnDeath method to the health component More... | |
![]() | |
virtual void | Update () |
Called every frame More... | |
![]() | |
virtual void | Reset () |
When this component is added we define its bounds. More... | |
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. More... | |
Protected Attributes | |
Vector3 | _positionLastFrame |
Vector3 | _raycastDirection |
Vector3 | _reflectedDirection |
int | _randomAmountOfBounces |
int | _bouncesLeft |
float | _randomSpeedModifier |
![]() | |
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 |
Additional Inherited Members | |
![]() | |
enum | MovementVectors { Forward , Right , Up } |
![]() | |
enum | WaysToDetermineBounds { Collider , Collider2D , Renderer , Undefined } |
![]() | |
virtual DamageOnTouch | TargetDamageOnTouch [get] |
Returns the associated damage on touch zone. More... | |
virtual Weapon | SourceWeapon [get] |
![]() | |
virtual Vector3 | Size [getset] |
![]() | |
Events | OnSpawnComplete |
Projectile class that will bounce off walls instead of exploding on impact
|
protectedvirtual |
Applies a bounce in 2D
hit |
|
protectedvirtual |
Applies a bounce in 3D
hit |
|
protectedvirtual |
Colliding endpoint
collider |
|
protectedvirtual |
Decides whether or not we should bounce
|
protectedvirtual |
Decides whether or not we should bounce
hit |
|
protectedvirtual |
On init we randomize our values, refresh our 2D collider because Unity is weird sometimes
Reimplemented from MoreMountains.TopDownEngine.Projectile.
|
protectedvirtual |
On late update we store our position
|
virtual |
On trigger enter, we call our colliding endpoint
collider |
|
virtual |
On trigger enter 2D, we call our colliding endpoint
collider |
S
void MoreMountains.TopDownEngine.BouncyProjectile.PreventedCollision2D | ( | RaycastHit2D | hit | ) |
If we get a prevent collision 2D message, we check if we should bounce
hit |
void MoreMountains.TopDownEngine.BouncyProjectile.PreventedCollision3D | ( | RaycastHit | hit | ) |
If we get a prevent collision 3D message, we check if we should bounce
hit |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
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)
MMFeedbacks MoreMountains.TopDownEngine.BouncyProjectile.BounceFeedback |
a feedback to trigger at every bounce
LayerMask MoreMountains.TopDownEngine.BouncyProjectile.BounceLayers = LayerManager.ObstaclesLayerMask |
the layers you want this projectile to bounce on
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
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)