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
  Rasterized Path Range issue proton 3 15 04-27-2024, 09:26 AM
Last Post: proton
  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_
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_

Forum Jump: