private void Play(bool direction = true) { float m = (rail.nodes[currentSeg + 1].position - rail.nodes[currentSeg].position).magnitude; float s = (Time.deltaTime * 1 / m) * speed; transition += (direction) ? s : -s; if (transition > 1) { transition = 0; currentSeg++; if (currentSeg == rail.nodes.Length - 1) { if (isLooping) { currentSeg = 0; } } } else if (transition < 0) { transition = 1; currentSeg--; if (currentSeg == -1) { if (isLooping) { currentSeg = rail.nodes.Length - 2; } } } transform.position = rail.LinearPosition(currentSeg, transition); //transform.rotation = rail.Orientation(currentSeg, transition); }
private void Play() { transition += Time.deltaTime * 1 / 0.45f; if (transition > 1) { transition = 0; currentSeg++; } else if (transition < 0) { transition = 1; currentSeg--; } transform.position = rail.LinearPosition(currentSeg, transition); // TEMPORARY DELETION transform.rotation = rail.Orientation(currentSeg, transition); }
void FollowTrack() { transition += Time.deltaTime * 1 / 2.5f; if (transition > 1) { transition = 0; currentSeg++; } else if (transition < 0) { transition = 1; currentSeg++; } transform.position = rail.LinearPosition(currentSeg, transition); transform.rotation = rail.Orientation(currentSeg, transition); }
private void Play() { if (setSpeed) { transition += Time.fixedDeltaTime * speed; } else { if (useEnt == true) { velocity = gameObject.GetComponent <Entity>().vel; } transition += Time.fixedDeltaTime * velocity.magnitude; } if (transition > 1) { transition = 0; current++; } else if (transition < 0) { transition = 1; current--; } if (current >= rail.nodes.Length - 1) { isComplete = true; } transform.position = rail.LinearPosition(current, transition); transform.rotation = rail.Orientation(current, transition); Vector3 rot = transform.rotation.eulerAngles; //use this to use rail like a water slide //transform.rotation = Quaternion.Euler(0, 0, rot.y); //Use this for rail grinding transform.rotation = Quaternion.Euler(0, 0, rot.x); //??? //transform.rotation = Quaternion.Euler(0, 0, rot.z); }