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 austen 2 · Mar 31, 2011 at 01:13 AM · javascriptguimousefollow

trying to get an object to follow mouse on GUI click

what i am trying to do is have a prefab follow my mouse when i click a GUI button then when i click again i want the object to stay there. im having trouble getting the object to move after i instantiate it. how would i make the object follow my mouse after instantiating? is there a way to do this using the DragRigidbody in the Standard Assets?

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
0

Answer by AngryOldMan · Mar 31, 2011 at 02:49 AM

I think what you want is info on click to move and then just basic knowledge of boolean functions and the GUI function to use 2D on screen buttons to turn sections of script "on and off"

Comment
Add comment · Show 4 · 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 austen 2 · Mar 31, 2011 at 03:18 AM 0
Share

i know how to do that but i dont know what variable in the dragrigidbody script to transform my prefab to

avatar image AngryOldMan · Mar 31, 2011 at 03:22 AM 0
Share

i never said dragrigidbody. look up click to move on unity answers and on google, many answers to do with diablo style click games, wow style click game etc they all ask the same thing as do you.

avatar image austen 2 · Mar 31, 2011 at 01:14 PM 0
Share

I think you misunderstood me. What i want is when i click my GUI button, i want an object to be instantianted then at the same moment, move to my mouse. After i click, the object should follow my mouse around until i click again (releasing the object).

avatar image AngryOldMan · Mar 31, 2011 at 01:43 PM 0
Share

I understand more clearly now. you still want the exact same thing but rather than click to move you want to click to turn on a boolean allowing part of the click to move script to start working (needs to be in function Update), think it may involve raycasting too, which would return your mouse's 2D screen postion to a location in your 3d environment.learn about using basic GUI's as that is the easiest part to this. Then learn how to script your particular move system, once you have some code post it here if you have problems, no one will just write you this code though.

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

instantiate button problem 1 Answer

How can I display text and change color of objects when I roll over them with the mouse? 1 Answer

Check if mouse is over a button 1 Answer

Camera follow mouse, remain inside bounds? 0 Answers

Setting Scroll View Width GUILayout 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