• 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 /
  • Help Room /
avatar image
Question by Nosmo · Sep 08, 2016 at 07:10 PM · cameracamera-movementplayer movementsmoothsmoothfollow

How to make camera follow player from point to point

I'm trying to write a script that follows the camera to different areas in the game but while it is in that area the camera is stationary.

public Transform target; public float smoothing = 2f;

 Vector3 offset; /

 // Use this for initialization
 void Start () {
     offset = transform.position - target.transform.position; 
 }
 void FixedUpdate (){ 
     Vector3 targetCamPos = target.position + offset;
     transform.position = Vector3.Lerp (transform.position, targetCamPos, smoothing * Time.deltaTime);
 }

I want to make it smoothly transition between the 2 points and Smoothing * time.deltatime takes care of that but its keeping the camera still while the character is in the area that im having trouble with

Also pause the character movement until the camera reaches its position

Do you have any suggestions?

Comment

People who like this

0 Show 0
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

  • Sort: 
avatar image

Answer by ArturoSR · Sep 08, 2016 at 08:01 PM

Hello there.

OK, you need to store the position point, then, after has been moved check if the camera position is the same as the desired point, your function still try to move it because there is nothing to tells it to not keep doing it, so, this way you can control more precisely the behavior of your camera, even you can add some interruption if your character changes his destination at certain event, cheers.

Comment

People who like this

0 Show 0 · 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

Answer by SoraMahiro · Sep 08, 2016 at 10:07 PM

I dunno if this helps, but what I did for a camera follow was I paired a camera to the player and set it for a display(for you this would depend on if the camera following is the main feed, if so check the display on the camera to 1) and then created a second camera, being the "Main camera" and set it to display 2. Also with the camera on player, turn off its audio listener or unity will complain about there being two audio listeners in the same scene. So what this did was allowed me to have a camera following my character and displaying in the game view, while having a secondary "Main camera" that picked up audio and could be used for a loading screen or a level over GUI, or a death GUI. It will also be smooth as long as your character motion is smooth.

Comment

People who like this

0 Show 0 · 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

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta on June 13. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

If player hits certain X value in opposition to Camera, shift camera question. 0 Answers

Locking Camera's rotation on a rolling character 0 Answers

Making camera follow and rotate player 0 Answers

Help about understanding ceratin command problem 1 Answer

my movement doesn't work after adding "follow player" script to camera 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