I can’t seem to figure out how Lerps work exactly. I mean, I understand the concept, but what I’m trying to do isn’t working. I’m trying to get a platform to Lerp to a specific X value from its current X position. However, when running the code, it goes no where and Debug.Log(Output) is telling me that the X value is just staying the same for whatever reason.
I’ve attached a copy of the code that controls the platforms. If you don’t want to download it, I’ll put it here as well.
Code
public class PlatformController : MonoBehaviour
{
float Output = 0;
float CurrentXPos;
@BlackPete : I fixed your first note by setting the accumulator as a field, but I’m not sure what you mean by the second note you made. I know it has to be a value between 0 and 1, so how can I stop it at 1? Or even make it go back and forth?
nb. Lerp is automatically clamped to (0,1) anyways.
Edit: if you want it to go backwards, as per one of your responses, check the value and if it’s >= 1, then maybe set a bool that says it’s going backwards. I dunno
@BlackPete Thanks, it seems to stop at 8 regardless if I use the Mathf.Min or just leave the Accumulator += value in.
However, both methods seem to yield an interesting result. The further to the left the platform spawns, the faster it goes, which I’m assuming has something to do with the percentages.
Edit: Also, the Mathf.PingPong did work, it’s just very fast.