Game Over

Help, support and information for our Game Framework Unity Asset.
If posting about the assets in the extras bundle then please use the appropriate forum.
Post Reply
bradjensen68
Posts: 67
Joined: Thu Dec 08, 2016 7:34 pm

Game Over

Post by bradjensen68 » Mon Jul 30, 2018 10:47 pm

So, I am trying to make a racing game and the idea is that you need to win a race to unlock the next race. However, if you do not win the race, you still get coins based on how you placed. So for example, if I get second place, I get two stars and 100 coins but I do not unlock the next race. So, I have the level set to "unlock with complete" and the scene scope set to "Game won when all stars got" furthermore, I have set "update player coins" to always. Now the problem is that I also have "game over" functionality based on the race package I am using, so I want to use that to determine when the race is over, but then to hand off the rewards, etc to Game Framework.

These setting work fine if the player wins the race. They get three stars, 200 coins,and the next race level is unlocked. However, if they come in second place, they do get two stars, the next level is not unlocked (correct), but they also do not get any coins (not correct). I am not sure what I am doing wrong. Here is the relevant code:

if (RaceManager.instance.GetPlayerCompetitor ().position == 1) {
level.StarWon (3, true);
level.StarWon (2, true);
level.StarWon (1, true);
LevelManager.Instance.Level.Coins += firstplaceprize;
}
if (RaceManager.instance.GetPlayerCompetitor ().position == 2) {
level.StarWon (2, true);
level.StarWon (1, true);
LevelManager.Instance.Level.Coins += secondplaceprize;
}
if (RaceManager.instance.GetPlayerCompetitor ().position == 3) {
level.StarWon (1, true);
LevelManager.Instance.Level.Coins += thirdplaceprize;

bradjensen68
Posts: 67
Joined: Thu Dec 08, 2016 7:34 pm

Re: Game Over

Post by bradjensen68 » Sun Aug 05, 2018 3:19 pm

OK, I think I figured it out. I needed to use GameManager.Instance.Player.AddCoins(xxxplaceprize); instead. I think what was happening was that if I came in second, then the game never "ended" according to Game framework and so the coins were never awarded. Now all seems to be working fine since I am adding directly to the player coins and not the level coins.

mahewitt
Site Admin
Posts: 252
Joined: Thu May 05, 2016 8:06 pm

Re: Game Over

Post by mahewitt » Tue Aug 07, 2018 7:04 pm

Glad that you found a solution. On the Game Over prefab / component there is also some options under Reward Handling that handle copying the level to the player score (None / Always / On Win). Setting the player score directly will also work though.

bradjensen68
Posts: 67
Joined: Thu Dec 08, 2016 7:34 pm

Re: Game Over

Post by bradjensen68 » Thu Aug 09, 2018 6:58 am

Yeah, the problem was that I am using the Racing Games Starter Kit to determine when the race was over. Then I awarded the stars and the coins through my code. If I awarded all stars, then also the Game Framework recognized that the game was finished "all stars awarded" and then unlocked the next level. This only happened when the racer came in first. However, I also wanted the racers in second and third to win coins and one or two stars repectively, but not to unock the next level. In RGSK, the game was "over". If I set the Game Framework to make the game complete based on coins, then the game was also over and the next level unlocked, which is not what I wanted. If I did not set it to "Game complete based on coins" than no coins where awarded because for Game Framework the game hadn't ended yet.

Anyway, this is a unique situation and the code I am using works fine so all is now good.

Here is my game, by the way http://hoverhero.website

Post Reply