Advertisement
Guest User

boxcontroller

a guest
Feb 25th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class BoxController : MonoBehaviour {
  5.  
  6. public bool collidesUp;
  7. public bool collidesDown;
  8. public bool coolidesRight;
  9. public bool collidesLeft;
  10.  
  11. // Use this for initialization
  12. void Start () {
  13.  
  14. }
  15.  
  16. // Update is called once per frame
  17. void Update () {
  18.  
  19. RaycastHit hit;
  20.  
  21. Debug.DrawRay (transform.position, Vector3.up, Color.green);
  22. Debug.DrawRay (transform.position, Vector3.right, Color.blue);
  23. Debug.DrawRay (transform.position, -Vector3.up, Color.green);
  24. Debug.DrawRay (transform.position, -Vector3.right, Color.blue);
  25.  
  26. if(Physics.Raycast(transform.position, -Vector3.up, out hit, 0.2f)){
  27. if(hit.collider.gameObject.CompareTag("Box")){
  28. Destroy (hit.collider.gameObject);
  29. }
  30. }
  31. if(Physics.Raycast(transform.position, Vector3.up, out hit, 0.2f)){
  32. if(hit.collider.gameObject.CompareTag("Box")){
  33. Destroy (gameObject);
  34. }
  35. }
  36. }
  37.  
  38.  
  39. void OnCollisionEnter2D(Collision2D target){
  40. if (target.gameObject.tag == "FinishLine") {
  41. Destroy (gameObject);
  42. }
  43.  
  44. if (target.gameObject.tag == "Box") {
  45. //GetComponent<Rigidbody2D> ().isKinematic = true;
  46.  
  47. }
  48.  
  49. }
  50.  
  51.  
  52.  
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement