Beispiel #1
0
    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);
    }
Beispiel #2
0
    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);
    }
Beispiel #3
0
    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);
    }
Beispiel #4
0
    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);
    }