05-17-2020, 09:10 PM
(This post was last modified: 05-17-2020, 09:11 PM by curvyuser007.)
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:
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
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