public override void OnContact() { PlayerBehavior player = ContactObject.GetComponent <PlayerBehavior> (); if (player) { player.Health -= Value; if (_knockback) { player.DisableMovementControl(); Rigidbody2D playerRigidbody2D = player.GetComponent <Rigidbody2D> (); Vector2 vel = playerRigidbody2D.velocity; float _knockbackForce = 300f; playerRigidbody2D.AddForce(vel.normalized * -_knockbackForce); Wait(0.1f, () => { player.EnableMovementControl(); if (_volatile) { Destroy(this.gameObject); } }); } if (_volatile && !_knockback) { Destroy(this.gameObject); } } }
private void OnTriggerExit2D(Collider2D collision) { if (collision.gameObject.tag == "Player") { GameObject ContactObject; ContactObject = collision.gameObject; ContactObject.GetComponent <CharacterPreset>().moveSpeed += 0.2f; } }
public override void OnContact() { PlayerBehavior player = ContactObject.GetComponent <PlayerBehavior> (); if (player) { player.Point += Value; Destroy(this.gameObject); } }