Advertisement
OwlyOwl

raycast

May 1st, 2020
906
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.40 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class EnemyView : MonoBehaviour
  6. {
  7.  
  8.     private void Update()
  9.     {
  10.         RaycastHit2D hit = Physics2D.Raycast(transform.position, transform.up);
  11.  
  12.         Debug.DrawRay(transform.position, transform.up * 10, Color.red);
  13.  
  14.         if (hit)
  15.         {
  16.             Debug.Log("Spotted!");
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement