Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. Update() {
  2. player = GameObject.FindGameObjectWithTag ("Player");
  3. //Debug.Log (player.transform.position + " " + transform.position);
  4.  
  5. Vector3 direction = (player.transform.position - transform.position).normalized;
  6. Debug.Log (direction);
  7. Ray ray = new Ray (transform.position, direction);
  8. RaycastHit hit;
  9.  
  10. Debug.DrawRay (transform.position, direction, Color.red);
  11.  
  12. if(Physics.Raycast(ray, out hit, 3f)) {
  13. gameObject.renderer.material.color = Color.blue;
  14. //Debug.Log("OK");
  15. }
  16. else {
  17. gameObject.renderer.material.color = Color.white;
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement