Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Strange thing happening when setting RelativePosition
#1
Brick 
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:

Code:
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
Reply
#2
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.
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Setting Spline to be used by Spline Controller FritsLyn 1 139 05-04-2020, 08:42 PM
Last Post: _Aka_
  Setting up Playmaker Lupp_ 7 1,227 12-28-2019, 06:26 PM
Last Post: _Aka_
  Some strange issue with generator douoht 9 4,712 01-07-2019, 04:13 PM
Last Post: _Aka_
  strange error pez111 5 4,226 12-23-2018, 04:34 PM
Last Post: _Aka_

Forum Jump: