Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Position in path relative to Z world axis
#5
In other words you want to find the spline position that matches the same Z "depth" as the player, right?
That's it! Smile

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.
Reply


Messages In This Thread

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a way to get the position of each ControlPoint in spline by API? Chanon 1 2,374 06-07-2025, 09:44 AM
Last Post: _Aka_
  Duplicate Prefab along path rickgplus 1 1,761 01-23-2025, 10:09 AM
Last Post: _Aka_
  Can't set CG Path Controller j95677 4 3,717 10-04-2024, 06:55 PM
Last Post: j95677
  Rasterized Path Range issue proton 7 4,829 04-30-2024, 11:17 AM
Last Post: _Aka_

Forum Jump: