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 dot · Oct 01, 2010 at 12:07 AM · mousescreen

input from mouse relative to screen dimensions- how to

I saw a few-lines-long code for it on forums somewhere, but I can't find it

in the effect of it, however if the mouse was in the centre of the screen - it gave my variable the value 0, if it started moving towards right (or left) side of the screen it gradually gained value, till it gained - for example 90.

so the var valueMouseX was 0 when mouse was in the middle, and if mouse was moved to right or left side - the value grew along with the distance - of the mouse - from the centre of the screen.

same thing coudl be done with MouseY.

do you have an idea what I'm talking about, and/or how to construct such a script? 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

1 Reply

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

Answer by dot · Oct 01, 2010 at 12:13 AM

ah. it was something like this :

var mouseX = 0;

function Update() { mouseX = 90 * ((Input.mousePosition.x - Screen.width / 2) / (Screen.width / 2)); }

if someone's interested.

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 jorgon · Sep 20, 2011 at 10:08 AM 0
Share

And once you have the mouseX position then you should do something like "Set$$anonymous$$ousePosition",don't you?

avatar image jorgon · Sep 20, 2011 at 10:10 AM 0
Share

I need to set the cursor of my mouse n the center of the screen...And I can't understand why this feature hasn't been implemented in the First Control Person Controller of the Unity Standard Assets...Any help?

avatar image syclamoth · Sep 20, 2011 at 10:21 AM 0
Share

It's in Screen.LockCursor- although, be aware that this also makes your cursor invisible.

avatar image jorgon · Sep 20, 2011 at 10:38 AM 0
Share

Ahhh...I've checked this early this morning and discovered this: why this people want their mouse pointer get disappeared from the screen?. I didn't realise that users want this double feature because after this, they substitute their common mouse pointer with another sprite or 3D object (as I was desiring in tehe next phase...) . So, Thank you!. These are things that we learn when we've never make a FPS game. I'm gonna continue with it then. I'd like to watch my common mouse pointer at this phase/stage in my personal developement but I could skip this. thanks!

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

2 People are following this question.

avatar image avatar image

Related Questions

Screen.lockCursor not working? 3 Answers

Script wont read array 2 Answers

How to make something happen when mouse on side of screen? 1 Answer

Mouse position script... 0 Answers

Drag GameObject with mouse in just one axis 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