EnemyController.cs 721 B

123456789101112131415161718192021
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class EnemyController : EntityBase {
  5. internal override bool isPressingCrouch() => false;
  6. internal override bool isPressDownJump() => false;
  7. internal override bool isPressingLeft() => false;
  8. internal override bool isPressingRight() => true;
  9. internal override void OnHitBorder() {
  10. Destroy(gameObject);
  11. }
  12. public float knockbackForceH = 30f, knockbackForceV = 15f;
  13. internal override void OnHitEnemy(Collision2D collision) {
  14. int face = collision.transform.position.x < transform.position.x ? 1 : -1;
  15. rb.velocity = new Vector2(face * knockbackForceH, knockbackForceV);
  16. }
  17. }