Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. [RequireComponent (typeof (Attacker))]
  6. public class Fox : MonoBehaviour {
  7.  
  8. private Animator anim;
  9. private Attacker attacker;
  10.  
  11. // Use this for initialization
  12. void Start () {
  13. anim = GetComponent<Animator> ();
  14. attacker = GetComponent<Attacker> ();
  15. }
  16.  
  17. // Update is called once per frame
  18. void Update () {
  19.  
  20. }
  21.  
  22. void OnTriggerEnter2D (Collider2D collider){
  23. GameObject obj = collider.gameObject;
  24.  
  25. // Leave the method if not colliding with defender
  26. if (!obj.GetComponent<Defender>()){
  27. return;
  28. }
  29.  
  30. // If collide with stone
  31. if (obj.GetComponent<Stone>()) {
  32. anim.SetTrigger ("jump trigger");
  33. } else {
  34. anim.SetBool ("isAttacking", true);
  35. attacker.Attack (obj);
  36. }
  37.  
  38. // Debug.Log ("Fox collided with " + collider);
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement