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 chunjai · Jan 01, 2011 at 07:03 AM · mousespawnbooleanballlimit

Limit click spawns to One

how would i limit a mouseclick to 1 so that functions will not repeat with a gajillion mouseclicks? for example, if a player clicks once, a beachball comes onto screen. unfortunately, if you keep clicking, more beachballs come, but there should only ever be the first one. once it's destroyed, a new one can be spawned. any help is appreciated. thanks!

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 Jessy · Jan 01, 2011 at 07:33 AM

var beachBallPrefab : GameObject;

private var beachBall;

function Update () { if (!beachBall && Input.GetMouseButtonDown(0)) beachBall = Instantiate(beachBallPrefab); }

"!beachBall" means there isn't a beach ball in the scene, either because you didn't make one yet, or because you destroyed it.

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 chunjai · Jan 01, 2011 at 07:40 AM 0
Share

it was right in front of me hahaha. i love how difficult these simple things can be for new developers like myself. thanks to you and @Yoshie$$anonymous$$aster for the answers.

avatar image
0

Answer by YoshieMaster · Jan 01, 2011 at 07:27 AM

Add a tag such as BeachballTag and then before instantiating the prefab check the following if statement:

JS:

if(FindGameObjectsWithTag("BeachballTag").length=0)

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 Jessy · Jan 01, 2011 at 07:40 AM 1
Share

This can work but is slow. Also, there's no reason to tag it "BeachballTag". A tag is a tag. "Beachball" could be appropriate.

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

How to prevent GameObject from spawning on top of each other? 1 Answer

Enabling/Disabling Cursor only when paused, Using FPS Controller Script, seem to be stuck! 0 Answers

boolean flag problem 1 Answer

Spawn Limit for enemies 1 Answer

Turning a menu on and off onclick in hololens 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