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 Random User · Nov 16, 2010 at 07:08 PM · mousescreencenter

How to always have the mouse curser in the center of your game ?

Hey guys im making a first person shooter and i have one problem with my view. At first when i start my game, im good untill i start moving alot and eventually my mouse is no longer in the center of my screen like how i wanted to be some times is on the side or bottom.

I want it so that i have a target in the middle of my screen at all times .

I use the MouseLook Script that comes whith the island demo. Any help would be sweet for i need to fix this to keep advancing.Ty in advance!! =)

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by diabloroxx · Nov 16, 2010 at 07:14 PM

Try having a look at the First Person Shooter tutorial /demo : http://unity3d.com/support/resources/tutorials/fpstutorial.html

Comment
Add comment · Show 2 · 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 Random User · Nov 17, 2010 at 01:49 PM 0
Share

Ty so much for this link it helped alot.

avatar image diabloroxx · Nov 17, 2010 at 03:44 PM 0
Share

Then please mark the question as Answered and close the question, unless you have anything else. It is always good to keep the community growing.

avatar image
1

Answer by Scribe · Nov 16, 2010 at 07:51 PM

You can use Screen.lockCursor: file:///Applications/Unity/Unity.app/Contents/Documentation/Documentation/ScriptReference/Screen-lockCursor.html

Comment
Add comment · Show 5 · 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 Random User · Nov 17, 2010 at 01:52 PM 0
Share

Ty for your help =)

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

Where do you apply this script?. I don't know how to apply this script from the Documentation. I've applied directly to the different elements of the First Person Controller and I haven't watched that the mouse icon should be centered in the middle of the screen...

avatar image LeeGibson · Sep 20, 2011 at 02:00 PM 0
Share

use it in the mouse look script that is attached to your first person controller

avatar image jorgon · Sep 21, 2011 at 09:13 AM 0
Share

Thanks, I will try it.

avatar image CursedScripter · Jan 16, 2012 at 04:51 AM 0
Share

Im using the exact script that the unity scripting reference provided, in c#, but it doesnt work... any ideas on why? i have no errors or anything

avatar image
0

Answer by Sibz9000 · Mar 10, 2019 at 01:51 PM

Locking the cursor

Note: This has a side effect of making the cursor invisible.

Use the following code to lock the cursor to the center of the screen.

Cursor.lockState = CursorLockMode.Locked

This can be ideal when using mouse input for pan/tilt or pitch/yaw type controls, i.e. camera pan/title or spacecraft movements


More info, including different lockstates can be found here:

Unity - Scripting API: Cursor

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 keep the mouse in center of screen 2 Answers

rotate camera on mouse reaching edges 1 Answer

How to stop mouse getting out of the game, my game is in webplayer? 2 Answers

click on screen to get the coordinate on the ground(x,z plane) 1 Answer

Aiming to center 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