0
\$\begingroup\$

I've got a small maze game where the player has to find a certain number of objects. If the player find all of them, I want the game to end. For now, I just simply want it to stop gameplay completely. I'll worry about ending it elegantly later. This is what I have, but I can't figure out what to put in the if statement. I can't seem to find a simple game state end function or anything like that. (Not really a whole lot of code to show for this. If for some reason someone needs to see more, please let me know and I can post other code, I just don't think anything else is relevant).

void APlayerCharacter::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);

    if (Score == 5)
    {
        //WHAT CAN I PUT HERE TO END GAME????
    }  

}
\$\endgroup\$
1
  • \$\begingroup\$ if (score==5). Single = means assignment. \$\endgroup\$
    – MSalters
    Oct 26, 2017 at 13:41

1 Answer 1

0
\$\begingroup\$

Here is something you might try.

They propose this function call:

FPlatformProcess::RequestExit(false);

In any case, it's a pretty bad idea doing this check in the Tick function. If you are picking objects, it's better to check if you got all the objects you need in the collider method, so you do it once every time you get a new object, not every tick.

Greetings

\$\endgroup\$
7
  • 1
    \$\begingroup\$ If that link ever breaks, then future users will only know it was something from "Here"... not very specific. Please always include at least a rough summary of the solution you're proposing rather than relying wholly on external links. \$\endgroup\$
    – DMGregory
    Oct 6, 2017 at 4:14
  • \$\begingroup\$ Since I'm not 100% sure it will work, I was expecting OP to try and update. Then either of us could expand :) I agree with you, but let's just wait \$\endgroup\$ Oct 6, 2017 at 4:17
  • \$\begingroup\$ I didn't use this exactly but was able to modify it to work. Thanks for the help! \$\endgroup\$ Oct 7, 2017 at 2:21
  • \$\begingroup\$ Glad it helped. Could you please update the question with the final result so it's clear what solved the problem? As @DMGregory suggested :) \$\endgroup\$ Oct 7, 2017 at 15:37
  • \$\begingroup\$ Solutions should go in answers, not in the question. ;) It's OK to post an answer to your own question to show the details of how you solved it. \$\endgroup\$
    – DMGregory
    Oct 7, 2017 at 16:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .