Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Sign in to follow this  
Aeleas

make different score for every level ?

Question

Hi

I'm asking you guys to clear this for me.

In my game there is a 4 scene (Main menu, levels map, first level, second level). every thing work fine. if the player want to win on the first level he had to get 100 point. but when i made the second level and change 100 point to 200. the 100 on the first level changed ! how to fix this ? how to make different points for evey levels in one script ?

 

 

Share this post


Link to post
Share on other sites

10 answers to this question

Recommended Posts

  • 0

Wrong section. See "need help".
Create for each world an entry key with the value "available" - a simple boolean. If in the previous level, you reached the score, boolean is true and you can load the next level.
Another way - use a simple integer so as to allow your levels (or not) to appear on the menu scene. Disable collider so as to deselect scenes which aren't available...
In fact, there is a many ways so as to do this script. Good luck ++

Please login or register to see this link.

Share this post


Link to post
Share on other sites

  • 0

You can use PlayerPrefs too. When you complete the level, you can say PlayerPrefs.SetInt("Score", PlayerPrefs.GetInt("Score") + 100);

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

this will save my score but i need to put on every level different value.

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

I read something about use array of classes.

can you give me example code of tutorail explaining this method. and what you mean by Dictionary ?

Share this post


Link to post
Share on other sites
  • 0

Do a simple on level load thing. If you provided a script to help it would be easier to set up be heres a helper.

Please login or register to see this code.

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

I will add the full script soon. now i'm not using my PC.

I will try to do your code. But when i saw it i got an idea.

Can i do this:

Please login or register to see this code.

its good or not ?

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.

 

public class Level {

    public int levelID;

    public int scoreToBeat;

}

 

then you can make a list of them for each level...

 

Level[] allMyLevels = new Level[10];

 

or you could use a dictionary.

public Dictionary<int,int> myGameLevels = new Dictionary<int,int>(); //first int is level index, second is score.

Share this post


Link to post
Share on other sites
  • 0

Here is my code, if you see any error or mistake inform me please.

Please login or register to see this code.

about the array. i do what you say but it give me error;

Please login or register to see this quote.

 

 

Share this post


Link to post
Share on other sites
  • 0

Var currlvl :into=1;

Var pointstonextlvl :int=100;

Var mypoints:into= 0;

Function update () {

If(mypoints>pointstonextlvl){

Currlvl++;

Pointstonextlvl+=100;

}

Function OnGUI {

//you can do it by yourself :)

}

//you need to created an function to add points it's very easy

}

Share this post


Link to post
Share on other sites
  • 0

I just get tire from using array (one is string other is int) an at end it give me error :-??there is no unity guide for this and many sites talking about VS console.

I will try again the class ((what RedCrusaderGames mentioned before)) and will check OnLevelWasLoaded method.

 

toutoutnn:

thank you for the code, i'm using c# (also new to c#). from what i see is same class method. Thank you again.

 

I will do my best. X_X

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...