Object to Waypoint script.
Hello everyone.
I'm working on a VR-Chat project and trying to make a "waypoint to waypoint" train.
I need to create a script that can make an object go from "waypoint 1" to "waypoint 2", but have no idear where to start.
Dose anyone here know where i could get a good idear of how C# or Java works in unity?
Or maybe even have a ref of something that could give an insight to how the code works?
I have worked a bit in LSL (Second life scriptting language) but know almost nothing of C and Java.
I hope everyone is having a good day!
Thanks in advance.
~Perg0
PS: Sorry for my terrible grammar, i'm trying my best to make it readable.
Answer by Pergo47 · Jul 30, 2020 at 09:45 AM
Nevermind think i got it now: i modified a script from a unity tutorial i found.
here is the resault:
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using System.Threading;
 
 
     public class Trainmovemnet : MonoBehaviour
     {
         // Adjust the speed for the application.
         public float speed = 1.0f;
     
         // The target (cylinder) position.
         private Transform target;
     
         void Awake()
         {
             // Position the cube at the origin.
             transform.position = new Vector3(-0.49f, -0.21f, -8.98f);
     
             // Create and position the cylinder.
             GameObject Cylinder = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
     
     
             // Grab cylinder values and place on the target.
             target = Cylinder.transform;
             target.transform.position = new Vector3(-0.49f, -0.21f, -8.98f);
     
     
     
         }
     
         void Update()
         {
     
     //######################################################
     
         forward:
             // Move our position a step closer to the target.
             float step = speed * Time.deltaTime; // calculate distance to move
             transform.position = Vector3.MoveTowards(transform.position, target.position, step);
     
             // Check if the position of the cube and sphere are approximately equal.
             if (Vector3.Distance(transform.position, target.position) < 0.001f)
             {
                 target.position = new Vector3(-160.49f, -0.21f, -8.98f);
                 goto back;
             }
     
     //######################################################
     
         back:
             {
                 // Move our position a step closer to the target.
                 transform.position = Vector3.MoveTowards(transform.position, target.position, step);
     
                 // Check if the position of the cube and sphere are approximately equal.
                 if (Vector3.Distance(transform.position, target.position) < 0.001f)
                 {
                     target.position = new Vector3(-0.49f, -0.21f, -8.98f);
                     goto forward;
                 }
             }
         }
     }
 
              Your answer