02-09-2015, 02:34 PM
(02-08-2015, 05:30 PM)'socoman3' Wrote: How could I check the segments bounds only to use the near ones?In 1.61 you'll need to calculate the bounds manually, but calling GetNearestPointTF() each frame kills performance anyways.
About the delta approach: Setting position directly of course produce jerks because this way you skip deltatiming. Perhaps try to alter the speed, the higher the delta, the the speed, if delta is almost 0, set the speed to 0. Though depending on your players speed the movement may feel too laggy.
Another (maybe simpler) idea:
Create a custom script and in fixed loop try something like:
Code:
float delta=player.Z-transform.position.z;
if (Math.Approximate(0,delta))
return; // nothing to move
Vector3 pos;
float tf;
if (delta>0){
float step=0.02f; // maybe inc/dec stepsize based on delta...
while (delta>0){
pos=spline.MoveFast(ref tf, step,...); // if MoveFast() is too inaccurate, increase cachesize or use Move()
delta=player.Z-pos.z;
}
} else {
// same as above, but with a negative stepsize
}
transform.position=pos;
Can be written more elegant, but should work.