• 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
Question by Koboh Z · Nov 10, 2010 at 09:26 AM · camerascreencursorkeyboardlock

Lock the screen

Hola I want to be able to lock the screen when i press the Q key on my keyboard but still be able to move the cursor around. Then when I press the Q key again the game goes back to normal. I have found very little info on this, I found lots of stuff to hide the cursor but that is not what i need. I do not know much about code I have no idea where to start I know I need to set up a key to stop the screen from moving but i can't figure out how to write in code "hey camera stop you making me dizzy I want to push that button stop moving cause i move the cursor" I play a demo that does this like i want with an inventory system added, I need inventory system too you know but I try to take that code apart just to get the camera stuff and got error this and error that. you don't have to write code for me just show me what does what you know like steps, do this then this then that and boom no more crazy camera. grasias from Mexico your brothers from another mother. adios amigos

Comment

People who like this

0 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 Koboh Z · Nov 10, 2010 at 02:09 PM 0
Share

I use this script makes camera stop but i lose cursor too, i want to freeze camera movement but still use cursor here is script I use. muchas grasias

private var fpcMouse; private var camMouse;

function Start () {

fpcMouse = gameObject.Find("First Person Controller").GetComponent("MouseLook"); camMouse = gameObject.Find("Main Camera").GetComponent("MouseLook");

}

function Update () {

if (Input.GetButtonDown ("Fire2")) { Screen.showCursor = !Screen.showCursor; fpcMouse.enabled = !fpcMouse.enabled; camMouse.enabled = !camMouse.enabled; }

}

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by Koboh Z · Nov 10, 2010 at 03:11 PM

grasias to all wonderful people who post here i found the info and was able to figure out how to do it!!!!! here is the script

private var fpcMouse; private var camMouse;

function Start () {

fpcMouse = gameObject.Find("Player").GetComponent("MouseLook"); camMouse = gameObject.Find("Main Camera").GetComponent("MouseLook");

}

function Update () { if (Input.GetKeyDown(KeyCode.Q)) {

Screen.showCursor = !Screen.showCursor;
Screen.showCursor = true;
fpcMouse.enabled = !fpcMouse.enabled;
camMouse.enabled = !camMouse.enabled;
 }

}

for anyone who might need it. to use make a game object you know one of them invisiable cubes then place this script in it and BOOM no more crazy camera. the current key is Q but you can change it. Might not be the way to do it but it stops the crazy camera.

Comment

People who like this

0 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Unity 3D Screen.lockCursor Problems 2 Answers

How do I create a toggle for showing cursor and then hiding cursor? 1 Answer

Screen.lockCursor messes my rotation 1 Answer

Modifying the pause menu to have screen.lockcursor on at start 1 Answer

How do I lock cursor to the center of the screen? 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