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 Pr3Z · Oct 31, 2011 at 06:06 AM · racepositions

Player Race Position

Hi all,

I'm trying to create a small race between some game objects.

When the player's game object (tagged and named as player) runs into the collider, I would like to work out whether the player has come 1st, 2nd or 3rd against their opponents.

I'm just trying to get an idea of how I should go about scripting the event.

Thank you :)

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
1

Answer by syclamoth · Oct 31, 2011 at 03:57 AM

You'd do something like this-

List<Player> winners = new List<Player>();

every time a player crosses the finish line, do this-

winners.Add(crossingPlayer);

Then at the end, loop through the 'winners' list, and get the first 3 members!

(You'll need to import System.Collections.Generic for this, btw)

Comment
Add comment · Show 1 · 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 Pr3Z · Oct 31, 2011 at 04:20 AM 0
Share

cheers man!

avatar image
0

Answer by fabclaudio · Mar 25, 2019 at 09:58 PM

(eng) Hello everyone, I state that I translate with a web translator, being Italian, I have a problem with a RaceManager script, the script is linked to a Car script, they work properly, I just can't seem to extrapolate the positions, everything I managed to do and extrapolate the number of cars present and the name of the first car at the start, please help me I'm getting crazy, I would just need to view the name of the cars in the correct order, or the number of the first player's position, I would prefer the names of the cars, I ask you to add some scripts in the explanation or the script to use, because I am a novice and translating with a web translator it is very difficult for me to understand what you are saying to me, I thank you in advance. (ita) salve a tutti, premetto che traduco con un traduttore web, essendo italiano ,ho un problema con uno script RaceManager, lo script e collegato ad un script Car, essi funzionano correttamente,solo che non riesco ad estrapolarre le posizioni ,tutto cio che sono riuscito a fare e estrapolare il numero di auto presenti e il nome della prima auto allo start, vi prego aiutatemi sto diventando pazzo, a me basterebbe anche solo visualizare il nome delle auto nel ordine corretto ,o il numero della posizione del primo giocatore ,preferirei i nomi delle auto ,vi chiedo di aggiungere qualche script nella spiegazione o lo script da usare, perché sono novizio e traducendo con traduttore web mi è molto difficile capire cosa mi state dicendo, vi ringrazzio in anticipo.

using UnityEngine; using System.Collections; using UnityEngine.UI;

public class RaceManager : MonoBehaviour { public Car[] allCars; public Car[] carOrder; public GameObject posizione;

public void Start() { // set up the car objects carOrder = new Car[allCars.Length]; InvokeRepeating("ManualUpdate", 0.5f, 0.5f);

}

// this gets called every frame public void ManualUpdate() { foreach (Car car in allCars) { carOrder[car.GetCarPosition(allCars) - 1] = car;

} posizione.GetComponent().text = "" + allCars.Length; }

}

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How would I efficiently implement race positions? 1 Answer

How do I make laps in a racing game? 5 Answers

Motorcycle Controller for Mobile 0 Answers

How to get y value of a large, tesselated, wave building plane at a specific world position 0 Answers

clarify me lightmapping please 2 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