Return After Reward

Hello I have been teaching myself how to use unity and code c# more actively over the past few months with udemy and phone apps,google, youtube yadda yadda. But i’m puzzled on getting my game to return to where it was after the reward video is played or closed. I’m just using the Integration code on the unity website But I can’t find anything about returning and i’m not having any luck on figuring this out.

example on how it works
//Timer hits 0
// Gameover panel SetActive = true
// Player Clicks RewardVideo
// Watches Ad
// Return < ---- My problem lays here
// Reward = + Time & Set Gameover false <— This works

public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
{
// Define conditional logic for each ad completion status:
if (showResult == ShowResult.Finished)
{
// Reward the user for watching the ad to completion.
reward.SetActive(true);
}
else if (showResult == ShowResult.Skipped)
{
// return to Scene. Gameover panel = true
}
else if (showResult == ShowResult.Failed)
{
Debug.LogWarning(“The ad did not finish due to an error.”);
}
}

Any help would be greatly Appreciated

~Aaron

So I THINK I figured out how I can do this, Game logic wise. Please let me know if you think i’m on the right track.

//Timer hits 0
// Gameover panel SetActive = true
// Player Clicks RewardVideo button
// Set player Prefs Players last location
// load video
// Watches
// load scene (last scene)
// set player Prefs Players last location
// set Time + Resume panel = true

I got it Just in case any other Noobs are stuck on something similar stick this in your “timer/floor/main script”

public GameObject player;

PlayerPrefs.SetString(“SceneNumber”, SceneManager.GetActiveScene().name);
PlayerPrefs.SetFloat(“PlayerX”, player.transform.position.x);
PlayerPrefs.SetFloat(“PlayerY”, player.transform.position.y);
PlayerPrefs.SetFloat(“PlayerZ”, player.transform.position.z);

Then in the video load script

void HandleShowResult(ShowResult result)
{
if (result == ShowResult.Finished)
{
// Reward the player

transform.position = new Vector3(PlayerPrefs.GetFloat(“PlayerX”), PlayerPrefs.GetFloat(“PlayerY”), PlayerPrefs.GetFloat(“PlayerZ”));
reward.SetActive(true);
}
else if (result == ShowResult.Skipped)
{
Debug.LogWarning(“The player skipped the video - DO NOT REWARD!”);

PlayerPrefs.GetString(“SceneNumber”);
SceneManager.LoadScene(“SceneNumber”);
transform.position = new Vector3(PlayerPrefs.GetFloat(“PlayerX”), PlayerPrefs.GetFloat(“PlayerY”), PlayerPrefs.GetFloat(“PlayerZ”));
GO_Panel.SetActive(true);

}
else if (result == ShowResult.Failed)
{
Debug.LogError(“Video failed to show”);
}
}

Hope that helps someone

forgot to add in the player prefs for the reward

//Reward The Player

PlayerPrefs.GetString(“SceneNumber”);
SceneManager.LoadScene(“SceneNumber”);

The below works without player prefs I reset unity and my problem seemed to vanish… Interesting

void Start()
{
adButton = GetComponent();
if (adButton)
{
adButton.onClick.AddListener(ShowAd);
}
if (Monetization.isSupported)
{
Monetization.Initialize(gameId, true);
}
}
void Update()
{
if (adButton)
{
adButton.interactable = Monetization.IsReady(placementId);
}
}

void ShowAd()
{
ShowAdCallbacks options = new ShowAdCallbacks();
options.finishCallback = HandleShowResult;
ShowAdPlacementContent ad = Monetization.GetPlacementContent(placementId) as ShowAdPlacementContent;
ad.Show(options);
}

void HandleShowResult(ShowResult result)
{
if (result == ShowResult.Finished)
{
Rewarded.SetActive(true);
reward.SetActive(true);

}
else if (result == ShowResult.Skipped)
{
Debug.LogWarning(“The player skipped the video - DO NOT REWARD!”);
GOPanel.SetActive(true);
}
else if (result == ShowResult.Failed)
{
Debug.LogError(“Video failed to show”);
}
}
}