lerp troubles

Hi guys n gurlz!

Argghh!

Having a bit of trouble with this!

I’m using the Update function to continuously run this code which is activated by an ios touch.

theSliderDummy.transform.position = Vector3.Lerp(theSliderDummy.transform.position, (Camera.main.ScreenToWorldPoint(new Vector3(touch.position.x,touch.position.y,iGuessTheCubesZgoesHereSomehow))), step); 

Essentially its using Lerp to make a cube follow the users finger around the stage, this seems to work fine up until i have the cubes parent object move along a spline… The result is that theSliderDummy’s depth from the camera doesn’t match the cubes z value therefore the slider goes off into the distance.

how can i make it that z depth in relation to the camera is locked at the cube’s.z localPosition?

You want the dummy object to not change it’s localPosition.z?

Store that value on Awake, and reset it to in every Update. You don’t have to do it inside the already gigantic lerp-call, just update the z-position after you’re done with the lerp.