Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class movetowards : MonoBehaviour
  6. {
  7.  
  8. public float velocidade = 1.0f;
  9.  
  10.  
  11. private Transform target;
  12.  
  13. void Position()
  14. {
  15.  
  16. transform.position = new Vector3(0.0f, 0.0f, 0.0f);
  17.  
  18.  
  19. GameObject cylinder = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
  20.  
  21. target = cylinder.transform;
  22. target.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
  23. target.transform.position = new Vector3(0.5f, 6.0f, -30.0f);
  24.  
  25.  
  26. }
  27.  
  28. void Update()
  29. {
  30.  
  31. float step = Time.deltaTime * speed;
  32. transform.position = Vector3.MoveTowards(transform.position, target.position, step);
  33.  
  34.  
  35. if (Vector3.Distance(transform.position, target.position) < 0.001f)
  36. {
  37.  
  38. transform.position = new Vector3(0.0f, 6.0f, 23.0f);
  39.  
  40.  
  41.  
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement