[Help]Slider to move an array in 3d space

Hello everyone,
I’m very new at Unity, trying to prototype an interaction using a slider to move an array of objects through a number of vector 3 positions.
This is what I’ve got so far, I can only make it work one-time using the slider, but have trouble continuing the movement.

here is the script(I’m super new at this, any feedback would be really really appreciated! )

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SlideShow : MonoBehaviour
{ public GameObject[] slides;
    public Vector3[] targetPositions;
    private int slideIndex;
    private float speed;
    // Start is called before the first frame update
    void Start()
    { // setting slides initial positions
        for(int i=0; i < slides.Length; i++)
        {
            slides[i].transform.position = targetPositions[i];
        }
       
    }
    // method start OnValueChange of a slider
    public void MoveSlideShow(float value)

    {
        speed = value / Time.deltaTime;
       
        for (int i = 0; i < slides.Length - 1; i++)
        {
            slides[i].transform.position = Vector3.MoveTowards(targetPositions[i],targetPositions[i+1],speed);
        }
    }
}

MoveSlideShow() is only called when the slider updates.

You are using the value (position in the slider) and dividing it by Time.deltaTime. I don’t see how that could possibly make sense honestly.

Are you trying to move a conga line of buttons through a predetermined path of positions? That seem weird but if so, perhaps some waypoint following tutorials might be useful to you.

You probably want to just use a tweening library like DOTween or LeanTween or iTween to do this. They take care of all the pesky timing and smoothing and easing, and generally you just say “go here” for the given objects.

1 Like

Thanks for the quick reply Kurt!
This is for developing UI in VR. I wanted to make a scrollview with buttons, but instead of scrolling on a flat surface, I’m looking to scroll on a curved surface, so the buttons will move closer to the camera and then away from the camera.