Advertisement
Kenkaster001

CYLINDER

Sep 10th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Cylinder : MonoBehaviour
  6. {
  7. public GameObject player;
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11.  
  12. }
  13.  
  14. // Update is called once per frame
  15. void Update()
  16. {
  17. Vector3 v = player.transform.position - transform.position;
  18.  
  19. float magnitude = v.magnitude;
  20. transform.LookAt(player.transform.position);
  21.  
  22. if (magnitude >= 3)
  23. {
  24. transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
  25. Vector3 n = v.normalized * Time.deltaTime;
  26. transform.Translate(n);
  27. }
  28. else if (magnitude < 3)
  29. {
  30. transform.localScale = new Vector3(2.0f, 2.0f, 2.0f);
  31. }
  32.  
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement