Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Update() {
- player = GameObject.FindGameObjectWithTag ("Player");
- //Debug.Log (player.transform.position + " " + transform.position);
- Vector3 direction = (player.transform.position - transform.position).normalized;
- Debug.Log (direction);
- Ray ray = new Ray (transform.position, direction);
- RaycastHit hit;
- Debug.DrawRay (transform.position, direction, Color.red);
- if(Physics.Raycast(ray, out hit, 3f)) {
- gameObject.renderer.material.color = Color.blue;
- //Debug.Log("OK");
- }
- else {
- gameObject.renderer.material.color = Color.white;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement