Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class SpotLight : MonoBehaviour {
  5.  
  6. public TerrainCollider terrainCollider;
  7. // Use this for initialization
  8. void Start () {
  9.  
  10. }
  11.  
  12. // Update is called once per frame
  13. void Update () {
  14. if ( SimulationControl.editorMode)
  15. {
  16. RaycastHit hit;
  17. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  18. if (terrainCollider.Raycast(ray, out hit, 400.0f))
  19. {
  20. print("Jest kolizja");
  21. transform.position = new Vector3(hit.point.x,hit.point.y + 50, hit.point.z);
  22. transform.LookAt(hit.point);
  23. }
  24. else
  25. {
  26. print("Nie ma kolizji");
  27. transform.LookAt(transform.position);
  28. }
  29. }
  30. else
  31. {
  32. transform.LookAt(transform.position);
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement