2
\$\begingroup\$

I have an intro animation scene in my game that I want to play the first time the player hits play from the main menu. How do I do this?

\$\endgroup\$
  • \$\begingroup\$ Persisting data when the game is closed is the whole purpose of the PlayerPrefs class. \$\endgroup\$ – Philipp Aug 5 at 17:32
  • \$\begingroup\$ @Philipp so its essentially an autosave for certain information? \$\endgroup\$ – Ethan K-B Aug 5 at 17:34
  • \$\begingroup\$ Yes, you could think of it like that. Although you can also save it manually in case your game tends to crash a lot. \$\endgroup\$ – Philipp Aug 5 at 17:36
  • \$\begingroup\$ @Philipp Yeah once my game size gets big again and causes lag I will work on a save feature. \$\endgroup\$ – Ethan K-B Aug 5 at 17:38
4
\$\begingroup\$

I've never done this, and I'm not familiar with Unity, but here's how I'd do it.

You could use the PlayerPrefs to implement that feature. When your player hits "Play", start first by checking if they have a preference saved. If they have, skip the intro, if not, save the preference and play the intro.

if ( PlayerPrefs.HasKey("HasSeenIntro")
{
    // skip to what shows up after they've been show the intro animation
}
else
{
    PlayerPrefs.SetInt("HasSeenIntro", 1);
    // play the intro
}

I think until you have a more complex mechanism of saving the game, this should be enough.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.