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.

"Way Points patrool and wait for seconds" Please Help me.

Discussion in 'Community Learning & Teaching' started by mehmetaskinbayraktar, May 16, 2022.

  1. mehmetaskinbayraktar

    mehmetaskinbayraktar

    Joined:
    Feb 26, 2022
    Posts:
    4
    Hi guys

    First of all, sorry for my english.

    My problem;

    I am a beginner coder.

    There is something I want to do in my project.

    My character will patrol the way point.

    While going to each point, it will turn its direction to that direction.

    At each point, it will wait for the time I set.

    There are at least 30 points on the way.

    When it reaches the last point, it will wait here for 5 seconds and continue from the second point.
     
  2. dterbeest

    dterbeest

    Joined:
    Mar 23, 2012
    Posts:
    386
    hey! since i dont really see a question, i'm going to assume you are looking for pointers on how to make this work with a script.
    I could write the script for you, but instead i'm going to just give you some pointers:
    - Start with some pseudo code, describe what you want the behaviour to do, and write out the different steps it needs to take.
    - Take a look at the different functions from Transform, like lookAt() and Translate() (https://docs.unity3d.com/ScriptReference/Transform.LookAt.html and https://docs.unity3d.com/ScriptReference/Transform.Translate.html)
    - WaitForSeconds works in something called a coroutine, Unity Docs has some great examples of this. (https://docs.unity3d.com/ScriptReference/Coroutine.html)
    - Take a look at Vector math, and especially on how to get a direction from 2 Vectors.

    Try and work through this, keep the Unity docs closeby, and if you have any specific problems we are here to help :)
     
    mehmetaskinbayraktar likes this.
  3. mehmetaskinbayraktar

    mehmetaskinbayraktar

    Joined:
    Feb 26, 2022
    Posts:
    4
     

    Attached Files:

  4. mehmetaskinbayraktar

    mehmetaskinbayraktar

    Joined:
    Feb 26, 2022
    Posts:
    4

    Hello again

    I wrote the code as in the file I attached
    But I still have an ongoing problem,
    My script works fine
    Waypoint index waits at last point,
    It stays there, I don't want it, please wait here for a few minutes and continue from where it left off.
     
unityunity