Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (!TargetWaypoint)
        {
            return;
        }

        Vector3 Direction = (TargetWaypoint.transform.position - CurrentWaypoint.transform.position).normalized;

        float maxMag = (this.TargetWaypoint.transform.position - this.CurrentWaypoint.transform.position).magnitude;

        lineProgress = lineProgress + (1.0f / (1.0f + CurrentWaypoint.Drag)) * MovementSpeed * Time.deltaTime;

        this.transform.position = CurrentWaypoint.transform.position + lineProgress * Direction;

        if (lineProgress >= maxMag)
        {
            this.CurrentWaypoint = this.TargetWaypoint;
            if (((CurrentDir == MovementDir.Forward) && !TargetWaypoint.Connected) || SelectNext == null || (CurrentDir == MovementDir.Backward && !SelectNext.Connected))
            {
                ToggleMovementDir();
            }
            this.TargetWaypoint = SelectNext;
            lineProgress        = lineProgress - maxMag;
        }
    }
Пример #2
0
 // Use this for initialization
 void Start()
 {
     this.transform.position = CurrentWaypoint.transform.position;
     if (!CurrentWaypoint.Connected)
     {
         ToggleMovementDir();
     }
     this.TargetWaypoint = SelectNext;
 }