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 Fred_Vicentin · Sep 10, 2013 at 09:12 PM · camera2dsmooth

Smooth Camera Follow

I done a simple code of a Camera Follow to a 2D Platformer, but i want to add a little delay on the follow, how can I do this ? It's possible on my code ?

 using UnityEngine;
 using System.Collections;
 
 public class CameraScript : MonoBehaviour 
 {
     public Camera mainCamera;
     public GameObject player;
     
     
     
     void Update () 
     {
         mainCamera.transform.position = new Vector3(player.transform.position.x, player.transform.position.y,transform.position.z);
     }
 }
 
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
1
Best Answer

Answer by DMCH · Sep 10, 2013 at 09:45 PM

One possibility is to make a (camera tracking) gameobject which will follow the player if the distance between the player and the game object is greater than a certain amount. When this amount is exceeded, get the object to follow the player until it catches up. Then, instead of getting the camera to follow the player, get it to follow this gameobject.

You could gradually increase the speed at which this gameobject moves to allow it to catch up, then reset it when it catches up.

I've never actually done this, so it's hard to say how well the implementation would work.

Comment
Add comment · Show 1 · 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 Fred_Vicentin · Sep 11, 2013 at 05:50 PM 0
Share

Hmm, that's looks nice idea, will try that tonight and answer you back, thank you

avatar image
0

Answer by flaviusxvii · Sep 10, 2013 at 09:20 PM

iTween has lots of utilities for smoothing movement.

http://itween.pixelplacement.com/index.php

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 Fred_Vicentin · Sep 10, 2013 at 09:22 PM 0
Share

I looked on iTween but don't found anything that I need to use, looked at documentation, and scenes, but nothing was useful =/

avatar image flaviusxvii · Sep 10, 2013 at 09:48 PM 0
Share

http://answers.unity3d.com/questions/166014/how-could-i-follow-a-moving-object-with-itween.html

avatar image Fred_Vicentin · Sep 11, 2013 at 05:49 PM 0
Share

I don't forgot you guy, tonight I will try that and if work I will response here

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

17 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

Related Questions

Why does the camera smoothly follow in one direction but not the other? 0 Answers

How to smoothly move a 2D camera without ghosting 3 Answers

Map level selection slide smoothly 3 Answers

Smooth Camera 2D 0 Answers

The sprite that is being followed by thr camera is very jittery and doesn't look very nice at all. 2 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