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
0
Question by Sirevix · Mar 24, 2015 at 01:20 PM · c#ontriggerenterloadlevelscore system

how can i load a scene when reaching certain score? Roll-a-Ball Project

Hello So i was watching the project roll a ball, instead of boxes i put coins and changed the game a little But in these videos it explains how to count score nothing about loading new scenes and stuff i fugured out by myself (wich is BIG thing) how to load a new scene i put a cube in the scene and a script like

 using UnityEngine;
 using System.Collections;
 
 public class LevelLoad : MonoBehaviour {
     void OnTriggerEnter(Collider other) {
         Application.LoadLevel("Scene2");
     }
 }


but the score is "counted" or "Stored" in the character script It looks like this

 using UnityEngine;
 using System.Collections;
 
     public class PlayerController : MonoBehaviour {
     public float speed;
     public GUIText countText;
     public GUIText winText;
     private int count;
 
     void Start ()
     {
         count = 0;
         SetCountText ();
         winText.text = "";
     }
 
     void FixedUpdate ()
     {
         float moveHorizontal = Input.GetAxis("Horizontal");
         float moveVertical = Input.GetAxis("Vertical");
         
         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
         
         GetComponent<Rigidbody>().AddForce(movement * speed * Time.deltaTime);
     }
 
     void OnTriggerEnter(Collider other)
     {
         if (other.gameObject.tag == "PickUp")
         {
             other.gameObject.SetActive(false);
             count = count + 1;
             SetCountText ();
         }
     }
 
     void SetCountText ()
     {
         countText.text = "Count: " + count.ToString ();
         if (count >= 7)
         {
             winText.text = "You May Now Pass To The Next Level!";
         }
     }
 }

How i do to be Unable to pass to the next level unless you have "7" Score ?

and now that we are here i have another question How can i make menu's and stuff?

If anyone know's a link to documentation or tutorials for this things or any one knows to answer here

Thanx a lot :D

Comment
Add comment
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

2 Replies

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

Answer by Digital-Phantom · Mar 24, 2015 at 01:41 PM

This tutorial will show you adding points / scores

http://unity3d.com/learn/tutorials/projects/space-shooter/counting-points

As for loading your next level at a certain score just a simple if statement will do that.

 If(score >= 7) //in this case 'score' is just whatever variable name you allocate to your score system.
 {
   //Load your level here
 }
 
 


quick reference to load level http://docs.unity3d.com/ScriptReference/Application.LoadLevel.html

:)

Comment
Add comment · Show 3 · 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 Sirevix · Mar 24, 2015 at 06:14 PM 0
Share

thanks for the help

but i just got rid of the box and added in the playerController

[CODE]

 void SetCountText ()
 {
     countText.text = "Count: " + count.ToString ();
     if (count >= 7)

     {
         winText.text = "You $$anonymous$$ay Now Pass To The Next Level!";
         Application.LoadLevel("Scene2");

     }

[/CODE]

And now i have another problem when i get to score "count" 7 the level loads in a secound and it doesn't give time for the text to show the "winText.text" only show's for a secound or less...

avatar image vintar · Mar 24, 2015 at 07:11 PM 0
Share

just add an Invoke that loads the next scene in however many seconds you want.

avatar image Sirevix · Mar 25, 2015 at 04:40 PM 2
Share

thanks I $$anonymous$$ADE IT !!! this was the first step to make Fifa 16 Well i have the ball :D (that's important) :))

avatar image
0

Answer by louis_k · Mar 26, 2015 at 07:36 AM

You may also use PlayerPrefs to save the score and retrieve it back

Good luck

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Application.LoadLevel ("lower") loads on start-up, not when triggered; Deadline is soon HELP! 3 Answers

Falldamage has no effect on my HB 2 Answers

OnTriggerEnter doesn't work 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