Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 djrequezt · Jun 25, 2011 at 08:41 PM · colliderrespawnretry

Attempt counter

Alright I'm going to make this as easy and simple as i can make it...

I'm working on this game IDK what to call it yet.....

Heres sum pics of it

alt text

Well Anyway as you can see on the pic there's a counter script im using but i dont want that!!

I wanna use a script that counts how many times a script is used.

Under each level theres a cube with a collider attached to it and when i hit that collider it will send me to a fixed respawn point

alt text

Heres the script for the respawn thing on the cube


var destination : Transform;

function OnTriggerEnter(other : Collider) { other.transform.position = destination.position; }


Now what i want to do is have a script that makes a gui on my camera and tells me how many times i hit that collider..

Therefore making an attempt counter

Kinda like in the impossible game

alt text


SO PLEASE HELP ME

im almost done with my game all i need is that

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
Best Answer

Answer by FLASHDENMARK · Jun 25, 2011 at 09:06 PM

var attemptsCounter : GuiText; // Add a guiText here

 var destination : Transform; // Where you want the player to spawn when it collides with the object.
 
 var attempts = 0;
 
 function OnTriggerEnter (hit : Collider)
 {
 if(hit.gameObject.tag == "Give the object you are colliding with a tag and write it here")
     {
 transform.position = destination.position;
 attempts += 1;
      }
 }
 
 function Update ()
 {
 attemptsCounter.text = ""+ attempts;
 }

Attach this to your player.

Very easy just adding a variable called attempts that gets added to when the player collides with the object and printing it out on a GUIText.

BTW What is that font called? It looks sweet.

EDIT: Sorry I can´t format the code properly.

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 djrequezt · Jun 25, 2011 at 09:09 PM 0
Share

its called coalition look it up at dafont.com

avatar image djrequezt · Jun 25, 2011 at 09:14 PM 0
Share

ok what do i attach this script to?? cause it aint working

it just gives me a zero the whole time

avatar image FLASHDENMARK · Jun 25, 2011 at 09:15 PM 0
Share

Your player(sphere).

avatar image FLASHDENMARK · Jun 25, 2011 at 09:22 PM 1
Share

I changed it up a little, should work now and be more understandable.

avatar image FLASHDENMARK · Jun 25, 2011 at 09:26 PM 1
Share

And thank you for that font. ;)

Show more comments
avatar image
1

Answer by bittam · Jun 25, 2011 at 08:50 PM

Add a OnTriggerExit function (and make sure the object.name that is exiting the trigger is the same object.name that had entered the trigger). if the object.name's match, you can increment your counter then. does this make sense?

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 bittam · Jun 25, 2011 at 09:07 PM 1
Share

go with what orange lightening said.. i think i got confused with another similar sounding post.

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

Refferencing to other scripts 1 Answer

Animation Script not working. 1 Answer

Audio play when object hit collision. 2 Answers

Gradually change distance fog over time with a collider object. 1 Answer

Respawn Problem 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