Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Position in path relative to Z world axis
#6
(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.
Reply


Messages In This Thread

Possibly Related Threads…
Thread Author Replies Views Last Post
  Incorrect mesh alignment after extrusion on curved path Thinkurvy 10 21 04-17-2024, 10:57 AM
Last Post: _Aka_
  Getting Distance from a World Point zorksox 3 5 04-16-2024, 07:30 PM
Last Post: _Aka_
  Rasterized Path Range issue proton 2 12 04-15-2024, 03:42 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_

Forum Jump: