Skip to content

Instantly share code, notes, and snippets.

@sabotai
Created November 14, 2016 21:40
Show Gist options
  • Select an option

  • Save sabotai/47f8fcc869792b6225bae98128bc8c7b to your computer and use it in GitHub Desktop.

Select an option

Save sabotai/47f8fcc869792b6225bae98128bc8c7b to your computer and use it in GitHub Desktop.
eg
using UnityEngine;
using System.Collections;
public class grab : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.right);
Debug.DrawRay(transform.position, Vector2.right);
if (hit.collider != null) {
Debug.Log("grabbed " + hit.collider.name);
} else {
Debug.Log("nothing");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment