Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        var z = startZ - _boat.Z;

        if (z > -deleteDist)
        {
            transform.position = _posRail.Eval(z);
        }
        else
        {
            Destroy(gameObject);
        }
    }
Ejemplo n.º 2
0
    public void Set(int layerIndex, float triggerDistance, int riverLength, Boat boat, float x)
    {
        if (Random.Range(0, 1f) < 0.5f)
        {
            transform.localScale = Vector3.Scale(transform.localScale, new Vector3(-1, 1, 1));
        }
        _boat  = boat;
        startZ = triggerDistance * layerIndex;
        var z = startZ - _boat.Z;

        _posRail = new Rail(triggerDistance, new Vector2(x, 0));
        for (int i = 0; i < riverLength - 6; i++)
        {
            _posRail.Add(Vector2.Lerp(Vector2.right * x, new Vector2(x, yMax), (float)i / (riverLength - 7)));
        }
        transform.position = _posRail.Eval(z);
    }