02-08-2015, 05:30 PM
In other words you want to find the spline position that matches the same Z "depth" as the player, right?
That's it!
I tried both ideas you suggested.
-Using GetNearestSplineTF() worked quite well, just a bit of delay between movements. However it hits performance. This is what I have in FixedUpdate:
float currentPosition = ASpline.GetNearestPointTF (player.transform.position);
followSpline.Position = currentPosition;
How could I check the segments bounds only to use the near ones?
-Alter the enemy until the Z-delta (between player<->enemy) is near zero.
I'm struggling with this (I don't know that much about scripting in general, and how the curvy code exactly works). However it seems a much faster option with what I made so far:
First try, just adding some value to the FollowSpline position in fixed update:
if (transform.position.z - player.transform.position.z < 0)
followSpline.Position += moveFactor;
Resulting in a not so smooth movement.
2nd try,
if (transform.position.z - player.transform.position.z < 0)
followSpline.Position += ASpline.InterpolateFast (moveFactor).z;
Resulting in a jaggy movement, as moveFactor is a fixed value...
How could I improve this to make a smooth movement?
Thanks a lot! Really.
That's it!
I tried both ideas you suggested.
-Using GetNearestSplineTF() worked quite well, just a bit of delay between movements. However it hits performance. This is what I have in FixedUpdate:
float currentPosition = ASpline.GetNearestPointTF (player.transform.position);
followSpline.Position = currentPosition;
How could I check the segments bounds only to use the near ones?
-Alter the enemy until the Z-delta (between player<->enemy) is near zero.
I'm struggling with this (I don't know that much about scripting in general, and how the curvy code exactly works). However it seems a much faster option with what I made so far:
First try, just adding some value to the FollowSpline position in fixed update:
if (transform.position.z - player.transform.position.z < 0)
followSpline.Position += moveFactor;
Resulting in a not so smooth movement.
2nd try,
if (transform.position.z - player.transform.position.z < 0)
followSpline.Position += ASpline.InterpolateFast (moveFactor).z;
Resulting in a jaggy movement, as moveFactor is a fixed value...
How could I improve this to make a smooth movement?
Thanks a lot! Really.