Example #1
0
    void Move()
    {
        if (transform.position.y >= MAX_Y_HEIGHT)
        {
            movementState = SpineFloorMovement.SFM_DOWN;
        }
        else if (transform.position.y <= MIN_Y_HEIGHT)
        {
            movementState = SpineFloorMovement.SFM_UP;
        }

        switch (movementState)
        {
        case SpineFloorMovement.SFM_UP:
        {
            direction = Vector3.up;
        }
        break;

        case SpineFloorMovement.SFM_DOWN:
        {
            direction = Vector3.down;
        }
        break;
        }

        Vector3 velocity = direction * speed * Time.deltaTime;

        transform.Translate(velocity);
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        int randomState = Random.Range(0, 2);

        switch (randomState)
        {
        case 0:
            movementState = SpineFloorMovement.SFM_UP;
            break;

        case 1:
            movementState = SpineFloorMovement.SFM_DOWN;
            break;
        }
    }