Advertisement
LittleAngel

AimFlashlight

May 17th, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class AimFlashlight : MonoBehaviour {
  5.  
  6. public Transform playerTransform;
  7. public float inspectDistance;
  8. public LayerMask ignoreLayer = -1;
  9.  
  10. private Transform thisTransform;
  11.  
  12. void Awake () {
  13. thisTransform = this.transform;
  14. }
  15.  
  16. void Update () {
  17. RaycastHit hit;
  18. Vector3 forward = playerTransform.TransformDirection (Vector3.forward);
  19. Physics.Raycast(playerTransform.position, forward, out hit, ignoreLayer);
  20. thisTransform.LookAt(hit.point);
  21. Debug.DrawRay (playerTransform.position, forward * inspectDistance, Color.red);
  22. Debug.DrawLine (thisTransform.position, hit.point, Color.blue);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement