コード例 #1
0
    void MoveFlipper()
    {
        // move up until max
        if (flipperStatus == FlipperStatus.movingUp && flipperAngleDifference < flipperAngleMax)
        {
            transform.Rotate(0, -flipperModifier * reverse, 0);
            flipperAngleDifference += flipperModifier;

            // hit max, be still
        }
        else if (flipperStatus == FlipperStatus.movingUp)
        {
            flipperStatus = FlipperStatus.still;
        }

        // move down until min
        if (flipperStatus == FlipperStatus.movingDown && flipperAngleDifference > flipperAngleMin)
        {
            transform.Rotate(0, flipperModifier * reverse, 0);
            flipperAngleDifference -= flipperModifier;

            // hit min be still
        }
        else if (flipperStatus == FlipperStatus.movingDown)
        {
            flipperStatus = FlipperStatus.still;
        }
    }
コード例 #2
0
    void CheckButtonPresses()
    {
        // check for left flipper press
        if (Input.GetKeyDown(activationKey))
        {
            flipperStatus = FlipperStatus.movingUp;
        }

        // check for left flipper release
        if (Input.GetKeyUp(activationKey))
        {
            flipperStatus = FlipperStatus.movingDown;
        }
    }
コード例 #3
0
    // for future jordan
    // need to use add force
    // base the amount of force to add on height of ball at click
    // which essentially emulates

    // Start is called before the first frame update
    void Start()
    {
        // flipper still to start
        flipperStatus          = FlipperStatus.still;
        flipperAngleDifference = 0;

        // the left and right paddle rotate opposite ways
        // this multiplier takes this into account in an easy way
        if (isReversed)
        {
            reverse = -1;
        }
        else
        {
            reverse = 1;
        }
    }