Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 adamtuliper · Jun 18, 2014 at 08:17 PM · rotationthird person controller

Ensure free camera lines up behind player

I have a free standing camera right that I'm trying to line up behind the player, so the camera is always looking at the player, but set back just a little. It almost works, but the more I move the more it is offset behind the player. The parent camera right should always line up directly behind the player.

Hierarchy is setup as follows:

-Free standing cam rig
----Main Camera (child of free standing rig)
-Player
//get amount to rotate camera var rotationAngle = speed * Input.GetAxis("Mouse X");

 //rotate player based on mouse
 player.transform.Rotate(0f, rotationAngle,0f);
 

 //Set camera right behind player
 parentRig.position = targetPosition;
 
 //Rotate rig around player
 parentRig.RotateAround(player.transform.position, player.transform.up, rotationAngle);


 //rotate camera in rig to look at character. Ideally we'd be lined up directly behind player, but if we need to offset the rig for panning purposes, this is here. 
 transform.LookAt(lookAt);    


If I move forward/back/right/left without the mouse, all works ok but with mouse movement it just seems to start getting offset from behind the player - ie the camera rig no longer lines up behind the player when the player rotates and ends up looking at the player from an angle. The crosshairs on the screen then don't line up with where the player is looking since they are gui based and the player is no longer centered to where the camera looks.

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 suribe · Jun 19, 2014 at 02:35 PM

It might probably be much easier to just make the camera be a child of the player GameObject, a little bit behind him. So when you rotate the player, the camera will rotate automatically without you having to do anything at all.

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

22 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

Related Questions

Character Controller strange collision bug 2 Answers

Make Third Person Character Rotate 1 Answer

Hitman Absolution Camera Study 0 Answers

Unity Asset Prefab Bug ThirdPersonController (left rotating bug / Snapping forward Always) 3 Answers

Flip over an object (smooth transition) 3 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