Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 alexnode · Mar 29, 2010 at 04:18 PM · cameratriggerupdatemouselooklock

Is it bad to add a mouse Lock at MouseLook Script?

I added an if condition in the MouseLook script, and I don't see any significant difference at the moment. I have the default FPController, a main and far camera. When I activate an onGUI trigger I add MouseLook.mouseLock = true and deactivate all cameras. Is that really wrong ? Should I do it in any other way ?

public float minimumY = -60F; public float maximumY = 60F;

public static bool mouseLock = false;

//so i can access the variable from everywhere.

float rotationX = 0F; float rotationY = 0F;

Quaternion originalRotation;

void Update (){

if (mouseLock==false)

//it all happens at the update...??!

{ if (axes == RotationAxes.MouseXAndY) { // Read the mouse input axis rotationX += Input.GetAxis("Mouse X") * sensitivityX; rotationY += Input.GetAxis("Mouse Y") * sensitivityY;

     rotationX = ClampAngle (rotationX, minimumX, maximumX);

.... etc

and here is how i call it ..

function OnTriggerEnter (hit:Collider) {

if((hit.gameObject.tag == "LiftGui") && (showMenu== false)) { MouseLook.mouseLock=true; showMenu = true; }

}

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
1
Best Answer

Answer by qJake · Mar 29, 2010 at 05:59 PM

So... your question is if your code is "wrong" or not? Because there's no right or wrong way to program something, I mean, sure, there are standards and practices and that sort of thing, but if your code works and shows no visible performance issue because of the code, I wouldn't say that it's "wrong"?

Short answer: If it works and doesn't make your game lag, it's fine.

Comment
Add comment · Show 3 · 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 alexnode · Mar 29, 2010 at 07:17 PM 0
Share

Thanks SpikeX, I added a boolean in the update function of mouseLook to enable and disable camera rotation when I have GUIs. I just wandered if checking all the time if it is enabled is the right way. I don't have loads of models and scripts yet in the game to check if that is an issue. I hope you are right, I will wait for a bit and tick your answer.

avatar image qJake · Mar 29, 2010 at 07:51 PM 0
Share

Yes, you can check booleans during Update() just fine... that code runs so fast and takes so little time, it's probably nearly immeasurable. If you knew how many calculations and conditional statements are run every Update() on a major production game, you'd laugh at this question. ;)

avatar image alexnode · Mar 30, 2010 at 08:40 AM 0
Share

LOL ! Apparently I don't ... 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

No one has followed this question yet.

Related Questions

Initialize character problem 1 Answer

How to make camera rotation relative to target. 3 Answers

Lock Camera to be within a box type area? 1 Answer

Disabling a child script within the parent. 0 Answers

Camera movement causing UI Pointer Enter/Exit triggers to break? 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