Skip to content

Instantly share code, notes, and snippets.

@moon-goon
Created March 2, 2016 02:59
Show Gist options
  • Save moon-goon/1bc9f802831c64603b7d to your computer and use it in GitHub Desktop.
Save moon-goon/1bc9f802831c64603b7d to your computer and use it in GitHub Desktop.
RaycastHit hit
void Start () {
}
void Update () {
bool found = Physics.Raycast(transform.position, transform.forward, hit, 7);
if(!found) return;
string name = hit.transform.name;
if(name!=null && name=='Cube') {
var targetObj = GameObject.Find(name);
targetObj.transform.Rotate(0, Time.deltaTime*50, 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment