Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. public class DestroyBox : MonoBehaviour, IGvrPointerHoverHandler {
  2.  
  3.  
  4. // Use this for initialization
  5. void Start () {
  6.  
  7. }
  8.  
  9. // Update is called once per frame
  10. void Update () {
  11.  
  12. }
  13.  
  14. void Destroy()
  15. {
  16. Destroy(this.gameObject);
  17. }
  18.  
  19. public void OnGvrPointerHover(PointerEventData eventData)
  20. {
  21.  
  22. Destroy();
  23. }
  24. }
  25. ------------------------------------------
  26. public Transform Player;
  27. int MoveSpeed = 1;
  28. int MaxDist = 1000;
  29. int MinDist = 0;
  30. float time = 5.0f;
  31.  
  32.  
  33.  
  34. void Start()
  35. {
  36.  
  37. }
  38.  
  39. void Update()
  40. {
  41. if (time >= 0)
  42. {
  43. time -= Time.deltaTime;
  44. return;
  45. }
  46. else
  47. {
  48. transform.LookAt(Player);
  49.  
  50. if (Vector3.Distance(transform.position, Player.position) >= MinDist)
  51. {
  52.  
  53. transform.position += transform.forward * MoveSpeed * Time.deltaTime;
  54.  
  55.  
  56.  
  57. if (Vector3.Distance(transform.position, Player.position) <= MaxDist)
  58. {
  59.  
  60. }
  61.  
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement