Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
4 captures
13 Jun 22 - 14 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 Amberlewis012 · Feb 16 at 02:08 AM · camera3dcamera-movementcamera rotateisometric

How to make a 3D camera rotate relative to the world?

I followed this tutorial from a few years ago about making an isometric view camera, and usually it works perfectly like the video, but somehow today when I followed the tutorial again the camera does not rotate as expected.

I would like to make it so the camera can rotate relative to the world (So its like the camera is rotating around a pivot and also facing towards it).

Everything else, movement, zoom, whatever works perfectly, just the rotation doesn't, and I've checked many times that nothing should be wrong. Hope someone can explain what the problem is and how to fix it! Thanks!

Here is the rotation parts of the camera controller script:

     public float movementTime;
     public float rotationAmount;
 
     public Quaternion newRotation;
 
     void Start()
     {
         newRotation = transform.rotation;
     }
 
     void LateUpdate()
     {
         HandleMovementInput();
     }
 
     void HandleMovementInput()
     {
         if (Input.GetKey(KeyCode.Q))
         {
             newRotation *= Quaternion.Euler(Vector3.up * rotationAmount);
         }
         if (Input.GetKey(KeyCode.E))
         {
             newRotation *= Quaternion.Euler(Vector3.up * -rotationAmount);
         }
 
         transform.rotation = Quaternion.Lerp(transform.rotation, newRotation, Time.deltaTime * movementTime);
     }
 }
 
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
0

Answer by MaxieNoob · Feb 16 at 02:15 AM

So, if what you're trying to accomplish is to have a 3rd person camera, sort of like roblox's camera, then its kinda simple:

         //CAMERA
 
         if (Input.GetAxis("Mouse ScrollWheel") > 0f & Scroll - .5f > .25f)
         {
             Scroll = Scroll - .25f;
         }
         else if (Input.GetAxis("Mouse ScrollWheel") < 0f & Scroll + .5f < 5)
         {
             Scroll = Scroll + .25f;
         }
         if (Input.GetKey(KeyCode.Mouse1))
         {
             Camera0.transform.position = RootPart.transform.position + new Vector3(0, 1, 0);
             Camera0.transform.rotation = Quaternion.Euler(Camera0.transform.rotation.eulerAngles.x + -Input.GetAxis("Mouse Y") * 3, Camera0.transform.rotation.eulerAngles.y + Input.GetAxis("Mouse X") * 3, Camera0.transform.rotation.eulerAngles.z);
         }
         Camera0.transform.position = RootPart.transform.position + new Vector3(0, 1, 0);
         Camera0.transform.position = Camera0.transform.position + Camera0.transform.forward * -Scroll;


This should work if you do these things: 1. Set the "RootPart" variable as a GameObject that you want it to pivot to 2. Set the "Camera0" variable to your MainCamera that you want to use 3. Add a variable for "Scroll" somewhere in the script

Basically, what this does is it lets you rotate around your "RootPart" and let you use the scroll wheel to scroll, and the Mouse1(right click hold) to rotate the camera @Amberlewis012

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 Amberlewis012 · Feb 16 at 03:09 AM 0
Share

@MaxieNoob Thanks for replying, your solution seems to be pretty good, but when i put in the code and everything necessary there were a few weird problems

the camera started shaking wildly after clicking Play, and scrolling to zoom in works, but when i scroll to zoom out, it only zooms out by 0.5 units and then it just stops zooming out...Any solutions?

(edited the zooming out part of this comment)

avatar image MaxieNoob Amberlewis012 · Feb 18 at 01:12 AM 0
Share

@Amberlewis012 maybe i didn't clarify enough? Sorry, but i forgot to say, there is a limit to the scroll so it doesn't phase through the character. I just copied it from a script i had, because i thought it'd help. For the camera shaking idk what was wrong with that, it might be because another script is interfering with the camera's position or rotation? Anyway for the zoom thing i recommend removing the "& Scroll - .5 > .25f" part of the if statement.

avatar image Amberlewis012 · Feb 16 at 06:50 AM 0
Share

Update, I found a solution by using RotateAround...and realised my question was probably way too stupid and unnecessary, but oh well. Thanks for replying though!

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

239 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 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

Screen is 2 cameras with each different properties. 1 Answer

Forward and back movements with a camera emulating an isometric view 1 Answer

How can i make the camera look up and down through keyboard keys? 2 Answers

Jerky 3rd Person Camera Following Movement and Rotation 0 Answers

I only rotated X, but Y and Z are shifting as well when I play the game. 1 Answer


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