Pain in the ass

I am trying to get a 3d text to move left -10 on the x axis in 1 second on a click in javascript but all atempts have failed and i am getting really pissed. Can anyone help?

I must say “Pain is the ass” is a very unhelpful title. Something like “Moving an object a certain distance over time” would be better.

I think this might get you close to where you are wanting to go. It’s a rough sketch (not tested). Good luck!

    // example: slide(Vector3(-10, 0, 0), 1)
    function slide(howMuchToSlide : Vector3, howLongWillItTake : float) {
        var timeSpent : float = 0.0;

        // keep moving until time is up
        while(timeSpend < howLongWillItTake) {
            // update our time counter 
            timeSpent += Time.deltaTime;

            // breaks total movement into however many steps needed to cover that 
            // distance within the time limit specified
            var step = howMuchToSlide / howLongWillItTake;

            // then move the object by that total step movement
            transform.Translate(step * Time.deltaTime);

            // make sure to wait for that long to make sure it takes effect
            yield WaitForSeconds(step * Time.deltaTime);
        }
    }