I have been developing an endless runner game for some time and I wanted it try and make the environment to bend horizon randomly like subway surfaces I download this Horizon Bending asset from the store which works beautifully. In the asset I have a method called ApplyCurvature(float val)
which applies it into the scene and bend the desired amount (right now it curves only left ApplyCurvature(5f);
).
I want it to be randomly change the curvature such as left, middle or right. I did try out Random methods just to make sure that I can apply curvature for each frame in the game, but it isn't what I want. I thought about using curves which is given by unity scripts but I don't know how to apply them. Can anyone help me on this? I'm new to unity3d so how can I use curves to apply the effect through the asset I have downloaded. Help would be appreciated.
using Battlehub.HorizonBending; //the asset package import
private float hb;
void Update ()
{
//HB.ApplyCurvature(5);
if (playerTransform.position.z - safeZone > (spawnZ - amtOfTilesOnScreen * tileLength))
{
if (activeTiles.Count < (NumberOfTilesThatFitOnScreen + 1))
{
var spawnedTile = SpawnTileAtFront();
activeTiles.Add(spawnedTile);
}
else
{
var movedTile = activeTiles[0];
MoveTileToTheFront(movedTile);
activeTiles.RemoveAt(0);
activeTiles.Add(movedTile);
//HB.ApplyCurvature(5);
hb = Random.Range(-5, 5); //Randomly bend road left and right
HB.ApplyCurvature(hb);
}
}
}
This above code is what I tried to randomly update the bend amount to left and right.