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 CameraDebugLog : MonoBehaviour
- {
- void Update()
- {
- if (Input.GetMouseButtonDown(0))
- {
- RaycastHit2D hit;
- if(hit = Physics2D.Raycast(new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y), Vector2.zero, 0.0f))
- {
- HandleRay(hit);
- }
- }
- }
- void HandleRay(RaycastHit2D hit)
- {
- Debug.Log("Raycast hit: " + hit.collider.name + " (X, Y, Z): " + hit.collider.transform.position);
- Interactable interactable = hit.transform.GetComponent<Interactable>();
- if (interactable != null)
- interactable.BeenHit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement