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 Klounas · Dec 05, 2015 at 06:15 PM · camera2dtopdownsmoothfollow

2D Top Down Camera Smoothing

Hello,

I have a camera that's a child of an object that I want it to follow (naturally), but when it comes to creating a smooth effect I am completely perplexed. Since the Camera is already following the object automatically how can I create a smooth effect without interfering with the transform component of the parent object? I've looked many threads and all the camera smoothing solutions seem to require a camera that's not coupled with the target. Does anyone have a solution for this?

Thank you.

Comment
Add comment · Show 1
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 Klounas · Dec 07, 2015 at 04:25 PM 0
Share

..... Bump?

1 Reply

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

Answer by wibble82 · Dec 07, 2015 at 04:30 PM

Hi

The simple fact is the correct solution is to not bind the camera rigidly to the object. This might initially seem the obvious approach - you want the camera to move with the object right?! But as you have discovered, as soon as you want subtly different behavior you're stuck.

Fortunately, it's not too difficult to make a camera that follows an object - you'll need to create a script for the camera that looks at its target object and works out where it wants to be each frame, then sets its transform accordingly.

Once you have that, the simplest way to achieve smoothing is to lerp towards your target position/orientation each frame. More advanced approaches exist that involve acceleration/deceleration, but lerps will be a good start.

Simple answer though - you need to decouple camera and object. Then all the camera smoothing examples on the internet will be helpful :)

-Chris

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 Klounas · Dec 07, 2015 at 06:54 PM 0
Share

Hi Wibble, thanks for your answer.

I do understanding the LERPing mechanic but I made it so that each player (multiplayer game) has its own camera in the prefab spawn. I guess I'll have to try to uncouple that and make it so that it assigns the main camera to the local player or something.

avatar image wibble82 Klounas · Dec 08, 2015 at 09:36 AM 0
Share

Yeah it's annoying but is unfortunately the right way to go. I guess if you want to take the simplest path of taking your current system to the new system, you could:

  • Create a script to your camera (if you don't already have one)

  • Leave the camera as a child of the player in your prefab

  • Add a public member called 'player I am following'

  • In the start function of your player script, find the child camera, tell it about 'this' so it follows the correct player, then set its transform.parent to 'null', thus detatching it

That's perhaps not the most elegant approach, but is probably a nice simple way of converting your current system to a new one without writing loads of new code!

avatar image wibble82 · Dec 08, 2015 at 10:06 AM 0
Share

p.s. Your call if this is the 'right' answer, but if it is could you mark it as such - it means other people with similar questions will know its along the right lines!

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Top-Down 2D game:How to make the camera move on hitting the sides of the screen? 2 Answers

2d top down Camera help 1 Answer

Any idea for smooth camera in pixel art sprite? 1 Answer

Camera looking down 1 Answer

Smooth Camera 2D Follow Player 0 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