- Home /
(unity 3d) Trying to make rail griding/sliding mechanic using PathCreator asset.
Hey! Making kinda sonic adventure 2 rail grinding using this asset (https://assetstore.unity.com/packages/tools/utilities/b-zier-path-creator-136082)
Have problem with snapping player to the rail: when I stop grinding and move to another point on the rail, i start sliding from where i finished the previous time. I already tried to make kinda way-point thing, but i realise that if i will continue working with this... SyStEm... it will take almost forever, i mean, yes, it's working and working good, but spend hours to figure out "where is this waypoint on curve" (asset using float to calculate point on a path), is just to much time consuming. And this is just one rail... On test scene... Not even in game... Also, if this is a stupid question, i'm a newby in unity and in c# codding. (GODDAMN why there are NO tutorials about making rail grinding mechanic?!?! Rail grinding is so cool!)
if this will help:
moving script:
public class grind : MonoBehaviour
{
public GameObject selfus;
public PathCreator rail;
public float speed = 5f;
public float distancetraveled;
public bool enabile;
private float direction = 1f;
public Camera cam;
public float fov = 100f;
public float grindfov = 110f;
public float grindfovTime = 50f;
private void Update() {
if(enabile)
{
distancetraveled += speed * Time.deltaTime;
transform.position = rail.path.GetPointAtDistance(distancetraveled, end);
cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, grindfov, grindfovTime * Time.deltaTime);
}
if(Input.GetKeyDown(KeyCode.R))
{
speed *= -1f;
direction *= -1f;
}
if(Input.GetKeyDown(KeyCode.Q))
{
if(enabile){
enabile = false;
if(direction >= 0f){speed = 150f;}
if(direction <= 0f){speed = -150f;}
cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, grindfov, grindfovTime * Time.deltaTime);
}
else if(!enabile){
enabile = true;
cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, grindfov, grindfovTime * Time.deltaTime);
}
}
if(Input.GetKeyDown(KeyCode.LeftControl))
{
if(speed >= 0f){speed += 10f;}
if(speed <= 0f){speed -= 10f;}
}
}
}
and waypoint script:
(made cube, used "Path Placer" script, made "is trigger")
public class grindwaypoint : MonoBehaviour
{
public float pointOnTheRail;
public GameObject player;
private void OnTriggerEnter(Collider other) {
if(other.tag == "player")
{
if(player.GetComponent<grind>().enabile == false)
{
player.GetComponent<grins>().distancetraveled = pointOnTheRail;
}
}
}
}
will happy to get some advices!
I really feel your pain............. with that being said.... did you figure it all out? and if so... can you share the solution? haha
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
save scene and load using binary file 1 Answer
Slide in one set direction 1 Answer
Spawning 3D Objects according to Data at JSON Matrix 0 Answers