fork download
  1. public class ZombieAttack : MonoBehaviour
  2. {
  3.  
  4. public int zombieCol = 0;
  5. float timer;
  6. public float timeBetweenAttacks = 0.5f;
  7. public int attackDamage;
  8. HealthScript enemyHealth;
  9. HealthCharacter playerHealth;
  10. public int i = 0;
  11. var pers;
  12.  
  13. void Awake()
  14. {
  15. playerHealth = GetComponent();
  16. enemyHealth = GetComponent();
  17. }
  18.  
  19. void OnTriggerStay2D(Collider2D col)
  20. {
  21.  
  22. if (col.gameObject.name == "Character")
  23. {
  24. zombieCol = 1;
  25. pers = col.gameObject.GetComponent();
  26. }
  27.  
  28. }
  29.  
  30. void OnTriggerExit2D(Collider2D col)
  31. {
  32. if (col.gameObject.name == "Character")
  33. zombieCol = 0;
  34. }
  35.  
  36. void Update()
  37. {
  38. if (zombieCol == 1)
  39. {
  40. if (pers != null && zombieCol == 1 && timer > timeBetweenAttacks && enemyHealth.HP > 0)
  41. {
  42. pers.TakeDamage(attackDamage);
  43. timer = 0f;
  44. }
  45. ZombieController move = GetComponent();
  46. move.playerSpeedForOtherScript = 0;
  47.  
  48. timer += Time.deltaTime;
  49. }
  50. }
  51. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(1,29): error CS0246: The type or namespace name `MonoBehaviour' could not be found. Are you missing an assembly reference?
prog.cs(8,3): error CS0246: The type or namespace name `HealthScript' could not be found. Are you missing an assembly reference?
prog.cs(9,3): error CS0246: The type or namespace name `HealthCharacter' could not be found. Are you missing an assembly reference?
prog.cs(11,3): error CS0825: The contextual keyword `var' may only appear within a local variable declaration
prog.cs(19,24): error CS0246: The type or namespace name `Collider2D' could not be found. Are you missing an assembly reference?
prog.cs(30,24): error CS0246: The type or namespace name `Collider2D' could not be found. Are you missing an assembly reference?
Compilation failed: 6 error(s), 0 warnings
stdout
Standard output is empty