void WasHit(GameObject Enemy) { if (miniHealthBarBackground != null) { miniHealthBarBackground.SetAlphaToOne(); miniHealthBar.SetAlphaToOne(); } Vector3 posDiff = transform.position - Enemy.transform.position; rb.AddForce(posDiff.normalized * knockbackStrength, ForceMode.Impulse); float damageTaken = Enemy.GetComponent <EnemyDamageDealt> ().damageDealt; if (godModeActive) { healthObject.TakeDamage(0.0f); } else { healthObject.TakeDamage(damageTaken); } ttc.ChangeColor(Color.red); ScreenShakeEffect.Shake(); EnableInvincible(); }
void CollisionCallback(Collision coll) { if (coll.relativeVelocity.magnitude > 3.0f) { mat.color = Color.red; transform.localScale = Vector3.one * 1.5f; ScreenShakeEffect.Shake(15, 0.05f, 5); } }
void CollisionCallback(Collision coll) { // If a strong vertical impact occurs, perform special effects. if (Mathf.Abs(coll.relativeVelocity.y) > 2.0f) { mat.color = Color.red; transform.localScale = Vector3.one * 1.5f; ScreenShakeEffect.Shake(15, 0.05f, 5); } }
// Use this for initialization void Start() { if (instance != null && instance != this) { Destroy(this); return; } else { instance = this; } }
void Start() { if (S != null && S != this) { Destroy(this); return; } else { S = this; } }
void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Enemy") { if (Hero.S.isHammer) { collision.gameObject.GetComponent <Monster>().Die(); ScreenShakeEffect.Shake(5, 1, 1); } return; } if (!hammerExactLeft() && !hammerExactRight()) { isColliding = true; } //print(gameObject.transform.position.y); if (collision.gameObject == lastTriggerGo) { return; } if (transform.position.y < collision.gameObject.transform.position.y + collision.collider.bounds.extents.y) { return; } lastTriggerGo = collision.gameObject; if (Hero.S.grounded) { return; } /* * print("vel: " + rigid.velocity); * print(Hero.S.bodyRigid.velocity); * print(rigid.velocity.x - Hero.S.bodyRigid.velocity.x); * print("pos: " + transform.position); * print(Hero.S.transform.position); * * if ((rigid.velocity.x - Hero.S.bodyRigid.velocity.x > 1 * && transform.position.x > Hero.S.transform.position.x) || (rigid.velocity.x - Hero.S.bodyRigid.velocity.x < -1 || && transform.position.x < Hero.S.transform.position.x)) { ||}*/ //print("should climb"); Hero.S.shouldClimb = true; ScreenShakeEffect.Shake(3, 1, 1); //rigid.velocity = Vector3.zero; ///// }
// Use this for initialization void Start() { if (instance != null && instance != this) { Destroy(this); return; } else { instance = this; } localReturnPosition = transform.position; }