Add pushback to rocket
This commit is contained in:
parent
a2340cbd25
commit
cc360b3932
@ -59,9 +59,14 @@ namespace Saltosion.OneWeapon.Guns {
|
|||||||
Collider2D[] NearbyColliders = Physics2D.OverlapCircleAll(transform.position, ExplodeRadius);
|
Collider2D[] NearbyColliders = Physics2D.OverlapCircleAll(transform.position, ExplodeRadius);
|
||||||
|
|
||||||
foreach (Collider2D curr in NearbyColliders) {
|
foreach (Collider2D curr in NearbyColliders) {
|
||||||
Vector2 dir = (curr.transform.position - transform.position);
|
Vector2 Delta = (curr.transform.position - transform.position);
|
||||||
float ScaledDistance = 1 - Mathf.Clamp((dir.magnitude - (ExplodeRadius / 3)) / (ExplodeRadius - (ExplodeRadius / 3)), 0, 1);
|
Vector2 Dir = Delta.normalized;
|
||||||
Bullet.DoDamage(ScaledDistance * 20, ScaledDistance * 2, curr, dir.normalized);
|
float ScaledDistance = 1 - Mathf.Clamp((Delta.magnitude - (ExplodeRadius / 3)) / (ExplodeRadius - (ExplodeRadius / 3)), 0, 1);
|
||||||
|
Bullet.DoDamage(ScaledDistance * 20, ScaledDistance * 2, curr, Dir);
|
||||||
|
if (curr.attachedRigidbody != null && curr.attachedRigidbody.bodyType == RigidbodyType2D.Dynamic) {
|
||||||
|
// FIXME: AcceleratedMovement currently overrides Rigidbody.velocity so this doesn't do anything
|
||||||
|
curr.attachedRigidbody.AddForce(Dir * 10f, ForceMode2D.Impulse);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do damage here, kill everyone
|
// Do damage here, kill everyone
|
||||||
|
Loading…
Reference in New Issue
Block a user