fr0stn1k

Unity(Task3and4_day2)_Kovylov

Mar 9th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class DamageWithCollision : MonoBehaviour
  4. {
  5. public Health Membership;
  6.  
  7. // Use this for initialization
  8. void Start ()
  9. {
  10. Membership = GetComponent<Health>();
  11.  
  12. }
  13.  
  14. private void OnCollisionEnter2D(Collision2D collision)
  15. {
  16. if (Membership != null)
  17. {
  18. Membership.TakeDamage(10);
  19. }
  20.  
  21.  
  22. }
  23.  
  24. private void OnCollisionStay2D(Collision2D collision)
  25. {
  26. if (Membership != null)
  27. {
  28. Membership.TakeDamage(1);
  29. }
  30.  
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment