Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by AusAndrew19 · May 22, 2012 at 10:32 AM · fps

How Would I Make The Game Go To Next Level After i Hit 1000 Points?

Hey Guys :)

I'm Currently Working on a FPS/Gothic/Zombie Game and its really turning out great! I Would Like To Implement Some Sort Of Script When i reach 1000 Points On The Score Manager it will Show a screen saying Level Completed and give me the option to go to next level (scene). I'm Using The FPSKitV1.2 There score manager is what I'm using ATM. if that's any help.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Lo0NuhtiK · May 22, 2012 at 10:59 AM 1
Share

You should be able to piece this together if you just look around. Points are points, doesn't matter what the game is about ; screen with text on it and somethin to allow you the option of going to the next level sounds like GUI to me ; and changing levels is changing levels whether you're going up one, down 5, or restarting the one you're already in. All those topics have multiple posts in here.

3 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by aldonaletto · May 22, 2012 at 11:58 AM

FPSKit is a great tool to help Unity users - but it's not an official Unity tool, thus most UA posters don't know it in depth (me included).
But maybe you can adapt the basic idea to your game: try to locate the script where the points are accumulated (ScoreManager?). Supposing you've found the script, and there's a variable called score that holds the current score, you should add the necessary code to it - something like this:

// declare this variable outside any function: var showDialog: boolean = false;

// add this line to Update: function Update(){ if (score > 1000) showDialog = true; ... (remaining Update code, if any) }

// create function OnGUI (or modify it, if already existing): function OnGUI(){ if (showDialog){ var next = Application.loadedLevel + 1; // calculate next level index if (next < Application.levelCount){ // if there exists a next level... if (GUI.Button(Rect(200,100,300,50),"Load next level")){ // show the button Application.LoadLevel(next); // and load it if button pressed } } } ... (remaining OnGUI code, if any) }

EDITED: Since you've posted the ScoreManager script, things became a lot easier: you don't need the variable showDialog neither the Update modification - all you need is to modify the OnGUI function as follows:

... function OnGUI(){ GUI.skin = mySkin; var style1 = mySkin.customStyles[0];

// JUST ADD THIS CODE: if (currentScore > 1000){ var next = Application.loadedLevel + 1; // calculate next level index if (next < Application.levelCount){ // if there exists a next level... if (GUI.Button(Rect(300, Screen.height - 110,280,60),"Load next level")){ // show the button Application.LoadLevel(next); // and load it if button pressed } } } // ***

GUI.Label (Rect(40, Screen.height - 80,100,60)," SCORE :"); GUI.Label (Rect(100, Screen.height - 80,160,60),"" + currentScore, style1); ...

Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AusAndrew19 · May 22, 2012 at 12:41 PM 0
Share

Wow, $$anonymous$$ate... Thank you so much!! Unfortunately i keep getting a error when implementing this saying.

assets/resources/Newscripts/Scoremanager.js(3,20): UCE0001 ';' expected. Insert a semicolon at the end.

Thing is it has one and im a little confused.

Would it be easier if i linked the script? @script ExecuteInEdit$$anonymous$$ode()

 var currentScore : int = 0;
 
 var time : float = 0.0;
 var hitCrosshairTexture : Texture;
 private var alphaHit : float;
 var hitSound : AudioClip;
 
 var mySkin : GUISkin;
 
 var pointsToNextRank : int = 50;
 var rank : int = 0;
 var rankSound : AudioClip;

function Update () {

 if (time > 0){ 
     time -= Time.deltaTime;
 }
 alphaHit = time;

}

function DrawCrosshair(){ yield WaitForSeconds(0.1); time = 1.0; audio.PlayOneShot(hitSound, .5); }

function addScore(value : int){ yield WaitForSeconds(0.2); currentScore += value;

 if(currentScore >= pointsToNextRank){
     rank++;
     PlayAudioClip(rankSound, transform.position, 1.0);    
     pointsToNextRank += currentScore;
 }

}

function PlayAudioClip (clip : AudioClip, position : Vector3, volume : float) { var go = new GameObject ("One shot audio"); go.transform.position = position; var source : AudioSource = go.AddComponent (AudioSource); source.clip = clip; source.volume = volume; source.pitch = Random.Range(0.95,1.05); source.Play (); Destroy (go, clip.length); return source; }

function OnGUI(){ GUI.skin = mySkin; var style1 = mySkin.customStyles[0];

 GUI.Label (Rect(40, Screen.height - 80,100,60)," SCORE :");
 GUI.Label (Rect(100, Screen.height - 80,160,60),"" + currentScore, style1);
 
 GUI.Label (Rect(40, Screen.height - 110,100,60)," LVL :");
 GUI.Label (Rect(100, Screen.height - 110,160,60),"" + rank, style1);
 
 GUI.color = Color(1.0, 1.0, 1.0, alphaHit);
 GUI.DrawTexture (Rect ((Screen.width - hitCrosshairTexture.width)/2, (Screen.height - hitCrosshairTexture.height)/2, hitCrosshairTexture.width, hitCrosshairTexture.height), hitCrosshairTexture);

}

(I had to remove the stuff i added cos it was currupting my game. But if you know why that script you showed me wasnt working would be appreciated.

avatar image AusAndrew19 · May 22, 2012 at 01:26 PM 0
Share

Sorry if i did that wrong. New to UA, :)

var boolean showDialog = false;

^^ is The only line im getting a error on now. It says that i need to add a semicolon at the end.

avatar image aldonaletto · May 22, 2012 at 11:50 PM 0
Share

$$anonymous$$y bad! That's what we get when writing in two languages - this declaration was a mix of JS and C#, which none of them would understand. It should be:

 var showDialog: boolean = false;

Answer fixed!

avatar image AusAndrew19 · May 23, 2012 at 04:06 AM 0
Share

Yeah that fixed that. Now i have another error... if (score > 1000) showDialog = true;

Unity cant recognise "Score"

avatar image aldonaletto · May 23, 2012 at 04:33 AM 0
Share

@AusAndrew, since you've posted the whole script, I will suggest a more specific alteration - only the OnGUI must have some code added. Take a look at the question - I edited it to add the necessary code.

Show more comments
avatar image
0

Answer by venkspower · May 23, 2012 at 04:51 AM

 var score : int;
 var a : int = 0;
 scoreText : GUIText;

 function Start(){
    score = 0;
 }

 function OnGUI(){
    scoreText.text = ""+score;
 }
 function Update(){
    score++;
    if(score > 1000){
      a = 1;
    }
    if(a == 1){
      Application.LoadLevel("LevelName");
    }
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by AusAndrew19 · May 23, 2012 at 07:24 AM

None of this is working... Keep getting so many errors. Guess this is too advanced for my noob skills. if anyone thinks they can help add me on msn, AusAndrew@hotmail.com thanks :)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

new to scripting need some fps controll help plz :) 2 Answers

fps change graphic 1 Answer

a strange problem ? 1 Answer

Simple Fps Prefab 1 Answer

Weapon switching using array 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges