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 KuboS0S · Sep 01, 2017 at 07:32 PM · cameratransformplayercontrollerplayercamera

Camera following the player in 3D - in object hirarchy or through scripts?

I am currently in the process of making a player controller script. Movement is done and I'm now facing the problem of camera movement.

Previously, I made the camera follow the player by making it a child of a child in the player - the camera pivot and the Camera itself. This let me simply offset the camera without changing the pivot and I didn't have to worry about tracking the player.

But now I'm rewriting the player controller script from scratch (as the old version was poorly written) and seeing some of the disadvantages of that system (more object references, harder-to-implement camera smoothing, etc.), I wondered if making the camera actually track the player would be better.

Though, I don't know the performance impact of using Transform.LookAt(player) and Transform.TransformPosition(offset) every LateUpdate(). Does anyone have more experience with this? I can't really use the profiler, nor can I measure performance impact in any other way that well, so help would be 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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by TheSOULDev · Sep 01, 2017 at 11:03 PM

While hierarchy controlled camera is good as a start, as you progress into further development you will always write a script that controls this movement - when through hierarchy the movement is robotic and unnatural, which is undesirable.

Honestly, if you do not know whether or not you should use a script controlled camera or a hierarchy controlled camera, you shouldn't even begin to think about performance, let alone attempt to optimize something that is most likely already running at 1000 FPS on the weakest of devices. Furthermore, if you can't use the Profiler don't even begin to consider optimization, you'll just end up with wrong conclusions. As they say, premature optimization is the root of all evil.

So the answer is yes - you want to control the camera through scripts.

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 KuboS0S · Sep 02, 2017 at 07:43 AM 0
Share

Well, I expect my game to be very performance-heavy, as hundreds (if not thousands) Rigidbodies are gonna be in the scene at one time, most of which will have a few behaviour scripts, but that's beside the point (early optimisation is always the root of all evil).

Thanks!

avatar image TheSOULDev KuboS0S · Sep 02, 2017 at 09:04 PM 0
Share

Well then you optimize that, not something that will have almost no load. What you're trying to do is saving pennies in a bank when you're spending 100$ bills daily, actually. If you think that your performance is going to be shitty because of physics, work on optimizing that, as that will change the performance most drastically. It is unlikely that you could create an optimized game that really sucks on a platform performance-wise, anyways, and any time you have doubts, just think about how magical the fast transform of an inverse root was and how some small changes can be game changing.

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

126 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

Related Questions

Which way of achieving player control is better - rigidbody functions or transform functions? 0 Answers

Camera and Controls 4 Answers

SideScroller Rotate 1 Answer

Negative Positions Breaks Raycasts 1 Answer

Change players state and controls in-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