Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class BoxController : MonoBehaviour {
- public bool collidesUp;
- public bool collidesDown;
- public bool coolidesRight;
- public bool collidesLeft;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- RaycastHit hit;
- Debug.DrawRay (transform.position, Vector3.up, Color.green);
- Debug.DrawRay (transform.position, Vector3.right, Color.blue);
- Debug.DrawRay (transform.position, -Vector3.up, Color.green);
- Debug.DrawRay (transform.position, -Vector3.right, Color.blue);
- if(Physics.Raycast(transform.position, -Vector3.up, out hit, 0.2f)){
- if(hit.collider.gameObject.CompareTag("Box")){
- Destroy (hit.collider.gameObject);
- }
- }
- if(Physics.Raycast(transform.position, Vector3.up, out hit, 0.2f)){
- if(hit.collider.gameObject.CompareTag("Box")){
- Destroy (gameObject);
- }
- }
- }
- void OnCollisionEnter2D(Collision2D target){
- if (target.gameObject.tag == "FinishLine") {
- Destroy (gameObject);
- }
- if (target.gameObject.tag == "Box") {
- //GetComponent<Rigidbody2D> ().isKinematic = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement