Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class DungeonRaycastCheck : MonoBehaviour
- {
- // Start is called before the first frame update
- public GameObject left;
- public GameObject Right;
- public GameObject Up;
- public GameObject Down;
- int Direction = 0;
- bool DirectionChecked = false;
- public Dungeon dSpawn;
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- }
- public void RaycastCheck()
- {
- if (DirectionChecked == false)
- {
- ///Direction = Random.Range(0, 4);
- if (Direction == 0 && Up == true)
- {
- RaycastHit2D hit = Physics2D.Raycast(Up.transform.position, Up.transform.TransformDirection(Vector2.up), 1f);
- Debug.DrawRay(Up.transform.position, hit.point, Color.green);
- if (hit != true)
- {
- print("didnt hit anything up");
- dSpawn.dungeonUp();
- DirectionChecked = true;
- }
- else { print("HitCube up"); }
- RaycastCheck();
- }
- else if (Direction == 1 && Down == true)
- {
- RaycastHit2D hit = Physics2D.Raycast(Down.transform.position, Down.transform.TransformDirection(Vector2.down), 1f);
- Debug.DrawRay(Down.transform.position, hit.point, Color.green);
- if (hit != true)
- {
- print("didnt hit anything down");
- DirectionChecked = true;
- }
- else { print("HitCube down"); }
- RaycastCheck();
- }
- else if (Direction == 2 && left == true)
- {
- RaycastHit2D hit = Physics2D.Raycast(Right.transform.position, Right.transform.TransformDirection(-Vector2.right), 1f);
- Debug.DrawRay(left.transform.position, hit.point, Color.green);
- if (hit != true)
- {
- print("didnt hit anything left");
- DirectionChecked = true;
- }
- else { print("HitCube left"); }
- RaycastCheck();
- }
- else if (Direction == 3 && Right == true)
- {
- RaycastHit2D hit = Physics2D.Raycast(left.transform.position, left.transform.TransformDirection(Vector2.left), 1f);
- Debug.DrawRay(Right.transform.position, hit.point, Color.green);
- if (hit != true)
- {
- print("didnt hit anything right");
- DirectionChecked = true;
- }
- else { print("HitCube right"); }
- RaycastCheck();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement