• 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 crogerson19 · Jun 14, 2022 at 02:25 PM · cameramousedeltatimepause game

How do I get my mouse (and first person camera) to multiply by deltatime?

I have a pause menu in my game, and I want my camera to stop when I $$anonymous$$t escape to bring it up. When the pause menu is active, the timescale is set to zero, so everyt$$anonymous$$ng should stop. However, the camera still moves, and I was told t$$anonymous$$s is the case because my mouse/camera are not influenced by deltatime. Here is the line of code I've been told is causing the issue:

                  //Don't multiply mouse input by Time.deltaTime
                  float deltaTimeMultiplier = IsCurrentDeviceMouse ? 1.0f : Time.deltaTime;


How should I change t$$anonymous$$s to make it so that the mouse is influenced by deltatime? If that's not the issue, what should I fix instead? I'm very new to all of t$$anonymous$$s, so thank you for any help you are able to give me!

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by stalwart5033 · Jun 14, 2022 at 03:47 PM

Hello, You can't do anyt$$anonymous$$ng about it with delta time.
You should use conditions like if (pauseMenuIsActivated == true)
for example:

 public float lookSpeed = 3;
 private Vector2 rotation = Vector2.zero;
 
 some void 
 {
   if (pauseMenuActivated == false)  // condition
   {
         rotation.y += Input.GetAxis("Mouse X");
         rotation.x += -Input.GetAxis("Mouse Y");
         rotation.x = Mathf.Clamp(rotation.x, -15f, 15f);
         transform.eulerAngles = new Vector2(0,rotation.y) * lookSpeed;
         Camera.main.transform.localRotation = Quaternion.Euler(rotation.x 
   * lookSpeed, 0, 0);
   }
 }
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
avatar image
0

Answer by Venividiviciuus · Jun 15, 2022 at 03:39 PM

If you are only using the mouse to move the camera then you have an essentially intuitive piece of code that causes you t$$anonymous$$s problem I do not yet have the skills to intervene in case I was using an external pad but in t$$anonymous$$s case it was not so I suggest you modify t$$anonymous$$s portion of code in your script where the rotation of the camera is present

The rest leave it as in t$$anonymous$$s thread and it should work. https://answers.unity.com/questions/1906887/player-camera-still-moving-when-paused.html?c$$anonymous$$ldToView=1906903#comment-1906903

Game paused >> Camera stopped

 private void CameraRotation()
          {
              // if there is an input
              if (_input.look.sqrMagnitude >= _threshold)
              {
                  //I deleted the useless deltaMultipler and multiply the rotation with deltatime
                  
                  _cinemac$$anonymous$$neTargetPitch += _input.look.y * RotationSpeed * Time.deltaTime;
                  _rotationVelocity = _input.look.x * RotationSpeed * Time.deltaTime;
  
                  // clamp our pitch rotation
                  _cinemac$$anonymous$$neTargetPitch = ClampAngle(_cinemac$$anonymous$$neTargetPitch, BottomClamp, TopClamp);
  
                  // Update Cinemac$$anonymous$$ne camera target pitch
                  Cinemac$$anonymous$$neCameraTarget.transform.localRotation = Quaternion.Euler(_cinemac$$anonymous$$neTargetPitch, 0.0f, 0.0f);
  
                  // rotate the player left and right
                  transform.Rotate(Vector3.up * _rotationVelocity);
               }
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 Venividiviciuus · Jun 16, 2022 at 10:46 AM 0
Share

@crogerson19 How is it going?

avatar image crogerson19 Venividiviciuus · Jun 20, 2022 at 02:02 PM 0
Share

Still a bit stuck, but I haven't been actively working on it. I'll let you know if I get it working

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

218 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Select/Drag/Drop Objects with a mouse 0 Answers

using left right keys to turn 1 Answer

rotate camera on mouse reaching edges 1 Answer

Camera movement independent of player control 1 Answer

how can i instantiate a GameObject in mouse position and in a special distance from the camera? 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