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 EliteFrame · Dec 12, 2017 at 07:16 AM · rotationquaternionsplanetthird-person-cameragimbal-lock

Third Person Camera on a speherical world

Hi all, I am trying to implement a third person camera which will rotate around the player’s X and Y axis. My player is always facing upright towards the planet’s center meaning the Y direction changes depending where you are on the planet. The problem is rotating around the player’s local space.

Desired outcome is a camera controller like in Grow Up.

If anyone can help me with a solution it would be highly appreciated, thanks.

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 Buckslice · Dec 12, 2017 at 10:36 PM

I would setup my Player hierarchy like so

 Player
     CamRot
         Camera

The Player rotation gets rotated based on the planets gravity, seems like you already have this working.

Mouse X would either rotate the player around the players up vector (if you want player to look in direction of mouse movement) or it would just set CamRots y rotation (you could rotate the player transform elsewhere based on player movement directions).

Mouse Y would set CamRots x rotation, and mouse zooming would change the z position of Camera. Let me know if you need more clarification, I could try writing up a simple script for this later. If it is confusing try creating the simple hierarchy and manually change the rotations to get a better understanding. Good luck!

Comment
Add comment · Show 1 · 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 EliteFrame · Dec 13, 2017 at 12:16 AM 0
Share

Hi Buckslice, thank you for the information, I will play around with the hierarchy and rotations tonight. I will let you know if it works.

Just for interest sake, would there be a different method that doesn’t involve parenting the camera to the player?

avatar image
0

Answer by EliteFrame · Dec 13, 2017 at 04:31 PM

For anyone else interested, I have figured out a method how to make an orbital camera controller without parenting the camera to the player.


First things first(thanks to @Buckslice) I was playing around with the hierarchy and did this: Create 2 different empty game objects "CameraRotY" and "CameraRotX" and place the in the hierarchy as follows:

   CameraRotY
       CameraRotX
              Camera

You can offset the "Camera" wherever you like behind the player and scale the "CameraRotY" for the distance between the player and camera. Create a empty game object that is centred and parented on the player or roughly where your pivot point is going to be. This Empty will basically be the target for "CameraRotY" to be in. You can then either add a smooth follow or set the position of "CameraRotY" to be at the target on the player. Then add this Java script to CameraRotY and Drag the game object which is the planet into the sphere variable.

 #pragma strict
 
 var sphere : Transform;
  
  function Update() {
      var v3 = transform.position - sphere.position;
      transform.rotation = Quaternion.FromToRotation(transform.up, v3) * transform.rotation;
  }

This will lock the x and z rotations on CameraRotY so only the up vector will be influenced by rotation.

Finally you can rotate CameraRotY's Y axis and CameraRotX's X axis with mouse x and mouse y input. Also just remember to give X's rotation a float clamp if that is what you need.

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

100 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

Related Questions

Weird behavior when setting eulerAngles directly 2 Answers

Why is rotation locking to an axis? 3 Answers

need my object to rotate between specific angles on the x axis 2 Answers

Make Quaternion affected by float 1 Answer

Reverse rotations problems... 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