I have a bezier curve drawn in my game and I’m moving an object (called “blind”) around the curve, in the form of an ellipsoid, like in this picture:
I have a total of 40 points (0-39) that make up the ellipsoid, and the points are gathered in a list called “fullPathWayPoints”. Since I don’t know of a way to smoothly interpolate between two points in a path that is not linear (this method will be ideal though), what I’m doing is linearly interpolating between each point, one by one, until the object (blind) reaches the target point. This works fine in the editor, in a PC build, and in a Mac build, although one of the drawbacks of using this method is that I cannot make the object go from point A to point B in a specific time that I can set up. Thus, the way is done is by speed instead: constant speed through all the points until the object reaches its destination. The code is the following:
private IEnumerator MoveBlind(int index, int finalPos)
{
tParam = 0;
if (index >= fullPathWayPoints.Count - 1) //this one resets the list so it doesn't go beyond the count limits
{
while (tParam < 1)
{
tParam += Time.deltaTime * _speed;
_objectPosition = Vector3.Lerp(_fullPathWayPoints[index], fullPathWayPoints[0], tParam);
transform.position = _objectPosition;
_currentPos = transform.position;
yield return null;
}
index = -1;
}
else
{
while (tParam < 1)
{
tParam += Time.deltaTime * _speed;
_objectPosition = Vector3.Lerp(fullPathWayPoints[index], fullPathWayPoints[index + 1], tParam);
transform.position = _objectPosition;
_currentPos = transform.position;
yield return null;
}
}
index += 1;
if (index != finalPos)
{
StartCoroutine(MoveBlind(index, finalPos));
}
else if (index == finalPos)
{
Debug.Log("Finished");
}
}
Code is not perfect, but at least get the job done (dirtily). As a side question, if someone knows of a way to interpolate between two points in a way that I can set up a time from point A to point B, and also that describes the path marked by the points, it’d be super useful.
So, the thing is that in the devices I tested (iPad, Xiaomi tablet, and iPhone), the blind (object) stutters while moving across the path. All devices are capped at 30 fps, so at first, I thought that that might be the reason. But everything else moves smoothly even at 30fps, which makes me now think that it might do something to do with the code (it’s not the first time that I experienced stutters while using Lerping methods (in other projects, though)). Any help is highly appreciated.
EDIT: I capped the game on the editor at 30fps and the stutter becomes more obvious.

