Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Move Object Problem

Discussion in 'Scripting' started by UMURAS, Jan 16, 2020.

  1. UMURAS

    UMURAS

    Joined:
    Jun 15, 2019
    Posts:
    18
    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:
    8,748
    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:
    18
    What tutorials should I follow about this problem?
     
  4. justLC

    justLC

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

    UMURAS

    Joined:
    Jun 15, 2019
    Posts:
    18
    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. justLC

    justLC

    Joined:
    Oct 16, 2018
    Posts:
    45
    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:
    18
    Thanks for your reply
     
  8. justLC

    justLC

    Joined:
    Oct 16, 2018
    Posts:
    45
    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.