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 Don 2 · Mar 24, 2011 at 05:54 PM · timercarpoints

Add points when player passes through something + Timer

Before we start, let me just put this out there. I started using Unity yesterday, and know little to none coding. With that said, here is the problem.

I have a car game with a bunch of ramps and stuff.

I want to have rings of some sort floating, after the ramps, so you can jump through them and earn points.

I also want a timer, so if you don't score the required points to pass a level, you go to a loose scene. If you score enough points, you go to the win scene.

I have no idea of how to even start to go about this.

Thanks in advance.

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

1 Reply

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

Answer by Statement · Mar 24, 2011 at 06:54 PM

You can make use of Invoke to create a lose timer. You can make use of OnTriggerEnter to add score and check for win conditions. You can make use of tags to check if the trigger is a "Ring" tagged trigger.

This script could be placed on your car but you probably want to change the Win and Lose functions.

var score = 0; var goal = 10; var timeLimit = 30;

Invoke("Lose", timeLimit);

function Lose() { enabled = false;

 // Load scene or do any other losing presentation.
 Application.LoadLevel("LoseScene");

}

function Win() { CancelInvoke("Lose"); enabled = false;

 // Load scene or do any other winning presentation.
 Application.LoadLevel("WinScene");

}

function OnTriggerEnter(other : Collider) { // If you have no other triggers, // you can ignore the tag check.

 if (!enabled || other.tag != "Ring") 
     return;

 if (++score >= goal) 
     Win();

}

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

No one has followed this question yet.

Related Questions

The timer starts after a collision with an object 1 Answer

How to set lap timer for network multiplayer 0 Answers

Script for Car 2 Answers

How to add waypoints/ timers for a car game! 1 Answer

advanced countdown timer help please 0 Answers


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