Hello! I have a hard time figuring out how to do a basic spline movement system as I had using Unity Splines. Maybe you can help?
For context, I'm working on a drone flying game on mobile. The drone is controlled via a joystick UI that manage both acceleration/deceleration and offset around the spline. Everything work as expected, but the drone takes forever to turn a curve (using bezier). I have watched your API video and I though I understood the TF vs Distance differences, I guess I'm confused as to how to use that information.
The whole movement loop is done in an Update method:
The EvaluateSpeed part is straigthforward. We lerp to max speed on input.Started and lerp back to 0 if input.Canceled.
Here is the MoveAlongSpline method:
I have tried to convert _splinePosition with float distance = _splineController.Spline.TFToDistance(_splineposition), but the behaviour was the same.
Any idea? Thanks
For context, I'm working on a drone flying game on mobile. The drone is controlled via a joystick UI that manage both acceleration/deceleration and offset around the spline. Everything work as expected, but the drone takes forever to turn a curve (using bezier). I have watched your API video and I though I understood the TF vs Distance differences, I guess I'm confused as to how to use that information.

The whole movement loop is done in an Update method:
Code:
private void Update()
{
ReadJoystickDirection();
EvaluateSpeed();
MoveAlongSpline();
}
The EvaluateSpeed part is straigthforward. We lerp to max speed on input.Started and lerp back to 0 if input.Canceled.
Here is the MoveAlongSpline method:
Code:
private void MoveAlongSpline()
{
if (!IsMoving && _hasFinishedMoving)
return;
_splinePosition += CurrentSpeed * Time.deltaTime;
// calculate position and rotation on the spline
Vector3 splinePoint = _splineController.Spline.Interpolate(_splinePosition, Space.World);
Vector3 tangent = _splineController.Spline.GetTangent(_splinePosition, Space.World);
// calculate offset
OffsetPosition();
// Rotate the player to face the tangent and move the player along the spline
_player.SetPositionAndRotation(splinePoint + _offset, Quaternion.LookRotation(tangent));
// Update mini map icon position
SplinePointUpdated?.Invoke(splinePoint);
}
I have tried to convert _splinePosition with float distance = _splineController.Spline.TFToDistance(_splineposition), but the behaviour was the same.
Any idea? Thanks
