Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Strange thing happening when setting RelativePosition
I'm making an infinite runner type of mobile game. I have a Spline (the road) and two SplineControllers (Player vehicle and enemy vehicle). I'm using Offset Angle and Offset Radius to place vehicles on separate road lanes.

Player has higher speed than enemy speed. In order to reuse the enemy object I simply move the enemy object far ahead of the player when the player passes by enemy vehicle. Below is part of the code on how I do it:

behindPlayerPosition = playerSplineController.RelativePosition - 0.01f;                  
if (behindPlayerPosition > enemyVehicleSplineController.RelativePosition)
   newPosition = playerController.RelativePosition + spawnDistance;
   enemyVehicleSplineController.RelativePosition = newPosition;

During runtime however, everytime the enemy vehicle gets placed ahead of the player, the distance between player and enemy is getting LONGER and LONGER. RelativePositions shows correct results though hence I'm baffled on what is going on. It's like as if the road is getting stretched even though dimensions are the same. 

Unity version: 2019.2.13f1
Curvy version: 6.1.0
That's a weird behaviour. I have no idea why it happens. Can you log yourSpline.Length to make sure it does not stretch?
In case this is indeed because of some bug of Curvy, and in case that bug was solved as a consequence of my work on controllers since 6.1.0, I advise you to update Curvy to the latest version. Keep a copy of your current version just in case.
Other than that, i would need a reproduction case to debug this
Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Setting instantiated object to spline, then starting movement? _RicO 3 9 06-28-2023, 06:01 PM
Last Post: _Aka_
  Lightmaps UV stretched even after setting split length to minimum dartboard 4 597 10-13-2021, 12:05 PM
Last Post: _Aka_
  Strange differences between editor and build jamesunity 1 1,079 07-20-2020, 08:49 PM
Last Post: _Aka_
  Setting Spline to be used by Spline Controller FritsLyn 1 1,318 05-04-2020, 08:42 PM
Last Post: _Aka_

Forum Jump: