EnemyHeavy.cs 923 B

123456789101112131415161718192021222324
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class EnemyHeavy : EnemyBase {
  5. public bool movingLeft = false;
  6. internal override bool isPressingCrouch() => false;
  7. internal override bool isPressDownJump() => false;
  8. internal override bool isPressingLeft() => movingLeft;
  9. internal override bool isPressingRight() => !movingLeft;
  10. //internal override void OnUpdate() {
  11. // bool shouldTurn = false;
  12. // if (Mathf.Abs(rb.velocity.x) > 0.001f && (rb.velocity.x > 0 == movingLeft)) shouldTurn = true;
  13. // if (shouldTurn) movingLeft = !movingLeft;
  14. //}
  15. public float knockbackForceH = 30f, knockbackForceV = 15f;
  16. internal override void OnHitEnemy(Collision2D collision) {
  17. int face = collision.transform.position.x < transform.position.x ? 1 : -1;
  18. rb.velocity = new Vector2(face * knockbackForceH, knockbackForceV);
  19. }
  20. }