Time game for Unity

Asked 2 years ago, Updated 2 years ago, 49 views

I want to make a game with Unity.
So I have a question
For example, the character is on the screen for 1 to 10 seconds. Click between 5th and 7th seconds to succeed
Failed before 5 seconds

Failed programming after 7 seconds Created
Yes.

I don't know what to start with.

Thank you for your cooperation.

unity3d

2022-09-29 21:45

2 Answers

Unity (not limited to but widely used languages and frameworks) has a textbook called tutorial for beginners to learn how to use.

The following are all materials in Japanese, so I recommend that you use them to learn how to use Unity and then ask specific questions here if there are any problems.


2022-09-29 21:45

float count;//Minor value to manage time
If boole gameActive=false;//true, you're in the middle of a game
void Update()
{
    if(Input.GetKeyDown(KeyCode.Space)) // Press the space key to start the game
    {
        Start the game with gameActive=true;//gameactive set to true
    }

    If(gameActive==true)//Play the game while gameactive is true
    {
        count+=Time.deltaTime; // Increase by 1 per second
        If(Input.GetKeyDown(KeyCode.Enter)) // Press Enter to run
        {
            If(count>=5&count=<7)/count is between 5 and 7
            {
                Debug.Log("Success");
            }
            else // count other than 5 to 7
            {
                Debug.Log("Failed";
            }
        }
    }
}

Please let me know if this is strange.
Anyway, I just started...


2022-09-29 21:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.