Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 LFZ2 · Nov 16, 2010 at 06:05 PM · click

Basic Mouse Click Anywhere for something to happen.

Is this possible with unity 3d? I know it is, but I haven't found a solution for this yet. I tried:

function OnMouseDown () 
        {
var snowball = Instantiate(snowballPrefab, GameObject.Find("SSpawnPoint").transform.position, Quaternion.identity); snowball.rigidbody.AddForce(transform.forward * 1000);
        }

and it works only if I click the snowball prefab. I would like to make this work by clicking anywhere on the screen. Any help is appreciated. Thank you!

Comment
Add comment · Show 1
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 Proclyon · Nov 16, 2010 at 06:17 PM 0
Share

It may help your code readability to hit the enter key, maybe just copy paste formatting trouble though:

Example: A = B; C = D; //Bad

4 Replies

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

Answer by Bampf · Nov 16, 2010 at 06:09 PM

Yes, it's easily done. See documentation for Input.GetMouseButtonDown or Input.GetButtonDown() for descriptions and code.

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 MaxLohMusic · Jan 20 at 07:02 AM 0
Share

Does anyone know the equivalent in the "new input system" in Unity? My specific use case is I made a menu selection that pops up where the cursor is, and now if they click anywhere on the screen, it should disappear.

avatar image
1

Answer by LFZ2 · Nov 16, 2010 at 06:49 PM

It is somehow not working for me, I tried Imput.GetMouseButtonDown example, I tried even Input.GetButtonDown()... still no working result it acts like I didn't do nothing.

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
avatar image
1

Answer by LFZ2 · Nov 17, 2010 at 03:47 PM

I made it work! if(Input.GetButtonDown("Fire1")) did the trick:) thank you!

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 LFZ2 · Nov 17, 2010 at 03:47 PM 0
Share

Input.GetButtonDown() is not correct for unity 3.1 Input.GetButton() is correct.

avatar image
0

Answer by lll4louis · Apr 14, 2019 at 11:14 AM

https://docs.unity3d.com/2019.1/Documentation/ScriptReference/Input.GetMouseButton.html I found this, for the latest version (today is 14-4-2019) .

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 do I get my UI Button to play my "fire animation" once? 2 Answers

Create UI raycast like a mouse Click 2 Answers

edit isTrigger by clicking on it, 1 Answer

Trigger animation OnMouseDown 0 Answers

Unity Lock Up and Mouse Clicking Issue 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