How to make the water level reduce faster?

Hi. I working on a game for my fyp project. its can be said 100% done. but i want to add one more function to my game which is the water level reduce faster when the player answer more questions. it is a 2D quiz game. But the concept is save the fish. Question will appear upside. player has to drag and drop the fish with the correct answer to the barrel. At the same time water that act as the timer is reducing. when the player answer correctly, water will start from the top again. For now the water reducing time is constant. i want it to be faster when the player answer more and more questions. Can anyone suggest the coding?

Refer to my answer below.

The line above the Start function, "bool facingRight" needs a semicolon at the end to denote the end of the statement.

2 Answers

2

I suggest a modifier that increases as more questions are answered.
For instance :

int modifier = 1;
float waterLevel = 0;
void onQuestionAnswered(){
    modifier += 1;
}

void raiseWaterLevel(){
    waterLevel += modifier;
}

So when a question is answered, change the modifier.
Then on each tick the water level is raised, add the modifier onto the water level.

Store your base speed value in an variable.
During movement of water level use that value as one of the parameters.

When you want to increase speed, add some value to the base speed value.

For example, pseudo code to help you understand (since you didn’t provide code that you use):

 float _moveSpeed = 0.5f;

    void IncreaseSpeedBy(float amount)
    {
        _moveSpeed += amount;
    }

    void Update()
    {
        transform.Translate(Vector3.forward * _moveSpeed * Time.deltaTime);

        if (Input.GetMouseButtonDown(0))
        {
            IncreaseSpeedBy(2.5f);
        }
    }

Create cube, add new script and paste this code in it. Run the game, click to increase speed.
Except that in your case, you will increase speed when your player answers enough questions.
You don’t even need function for it, you can just add amount to base value from anywhere like so :

 _moveSpeed += amount;

Now that is just an example. You could use base value and use another value for boost, then change this boost value accordingly. In that case if you “drop” boost to 0f, you still have water moving at base speed.

Edit : Code applies to 3D objects, but concept is exactly the same.

can u check my coding? where should i embed your code?

Assets/Scripts/character.cs(18,30): error CS1525: Unexpected symbol `=' this message pops up in the console window when I put // Use this for initialization void Start () { myRB = GetComponent<Rigidbody2D> (); myAnim = GetComponent<Animator> (); facingRight; = true;