• 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
1
Question by Arman · Dec 27, 2010 at 11:18 AM · iphone

Camera Focus on Object

I have an object which is moving around on the plane, I want that, if object move in some direction, camera also move with object. Please guide me how can I do this.

Sorry for my bad english

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
3
Best Answer

Answer by Sebas · Dec 27, 2010 at 11:25 AM

The easiest way would probably be to make the camera a child of the object. If you move the object, the camera will move along.

If it's enough to only "focus" on the object as in 'looking at the object', try to use Transform.LookAt

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 Arman · Dec 27, 2010 at 11:41 AM 0
Share

@Sebas, I have tried Transform.LookAt, but actually I want that camera moves with the object.

avatar image Sebas · Dec 28, 2010 at 01:03 PM 0
Share

In that case, the parent/child solution might be best and easiest. You could also apply any movement to camera and object individually, but it really depends what you need this functionality for.

avatar image darthbator · Jul 23, 2012 at 01:05 AM 0
Share

What I do in this case is write a script that targets the transform of whatever I want the camera to look at. Then I rotate the camera at it and use a LERP to move it around to where I want. Something kinda like this

void lookTarget (Transform _lookTarget) { Quaternion lookAt = Quaternion.LookRotation(_lookTarget.position - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, lookAt, turnSpeed); transform.position = Vector3.Lerp(transform.position, _lookTarget.position + camOffset, target$$anonymous$$oveSpeed); }

avatar image
0

Answer by FLASHDENMARK · Dec 27, 2010 at 11:30 AM

If i understand your ? right then you can use "Smooth follow" to make the camera follow a object when it moves.

Just search "Smooth follow" in the search bar in unity 3D and select "Smooth follow" and attatch it to the camera, and set the target to the object you want the camera to follow. Then when the object moves the camera konstantly looks at it.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

A node in a childnode? 1 Answer

iPad touch scripting... 0 Answers

Whats the best way to setup a screen like this... 0 Answers

How do I invert the Y axis in Penelope tutorial? 3 Answers

iPhone tap on object with tag and do something? 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