In 2D. I would like to make a rail(for a train game) sprite in which you can manipulate the end points to get a smoothly turning railroad. Just give me an idea on what’s the best way to go about it. Thanks.
So I followed this tutorial got a bezier(smooth) curve which I could manipulate and add up more to it and then used two line renderers(which follow their spline) to draw the sides of my rails (which always stayed at the same distance, making it all work) and then the idea was to depending on the distace of the rail curve to create many new line renderers(in between my two main long curves) every n units but I didnt complete the second part of the idea cause it was too much effort for a small project.
@LocalNoob
Look into Unity spline solutions. I believe this asset might be of use to you:
Unity Asset Store - The Best Assets for Game Making (Curvy - $50)
Here is another cheaper one to check out:
Unity Asset Store - The Best Assets for Game Making (Simple Waypoint System - $15)
This tutorial is also very helpful if you would like to code a script on your own:
Curves and Splines, a Unity C# Tutorial (it is in 3D though)
If you don’t need it to be pin-point accurate (like just an animation) I would simply make a few different images in Photoshop and make an array containing with each image and then do something like this.
Update(){
timer += Time.DeltaTime
if(timer > animateFrameTime && isAnimating)
{
timer = 0;
showNextImageInArray();
if(imageShowing == imageToStopAt)
isAnimating = false;
}
}
This way you can choose the time it takes for each image to show and you can create in-between images so it looks like a smooth transition. : )