Search Unity

Move Object Problem

Discussion in 'Scripting' started by UMURAS, Jan 16, 2020 at 5:27 PM.

  1. UMURAS

    UMURAS

    Joined:
    Jun 15, 2019
    Posts:
    9
    How do we move an object to a certain point, stop it and move it after a while?
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    7,058
    Have you done any of the beginner tutorials at all? This is very basic tutorial kind of stuff, so I think you'd benefit from running through the tutorials.
     
  3. UMURAS

    UMURAS

    Joined:
    Jun 15, 2019
    Posts:
    9
    What tutorials should I follow about this problem?
     
  4. justinLC

    justinLC

    Joined:
    Oct 16, 2018
    Posts:
    24
  5. UMURAS

    UMURAS

    Joined:
    Jun 15, 2019
    Posts:
    9
    thank you for your answer but that's not what I mean as an example transform.Translate(Vector3.forward * Time.deltatime * 10);
    I want to stop a moving object with this code and move it again after a while.
     
  6. justinLC

    justinLC

    Joined:
    Oct 16, 2018
    Posts:
    24
    Code (CSharp):
    1. if (Vector3.Distance(transform.position, startPosition) < distanceToMove || condition to start moving again)
    2. {
    3. moving = true;
    4. }
    5. else moving = false;
    6.  
    7. if (moving)
    8. {
    9. your moving code
    10. }
     
  7. UMURAS

    UMURAS

    Joined:
    Jun 15, 2019
    Posts:
    9
    Thanks for your reply
     
  8. justinLC

    justinLC

    Joined:
    Oct 16, 2018
    Posts:
    24
    No problem. If you want to make it stop after a certain time and then start moving again after some time, instead of basing this off of distance, I personally recommend using Coroutines.
     
unityunity