Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Juancito · Mar 18, 2011 at 03:56 PM · camera2dcamera-movement

following camara issue

Hello guys,

I started with Unity development some weeks ago and still learning a lot, but I'm facing a very strange issue involving a following camera.

I'm using scripts taken from the standard assets Unity provides, but the camara is not smooth when the object is moving fast (rigidbody.velocity > 60).

I uploaded a youtube video to show this odd issue. In the top side of the video you'll see a static camera showing that the object movement is smooth, and in the bottom side you'll see the following camera (it's a 2D following camera). Note that when the object goes fast, it starts to glitch.

EDIT: Sorry I forgot to add the video link: http://www.youtube.com/watch?v=IMH12OHPS9U

This is the JS code used for the camara (SmoothFollow2D):

var target : Transform; var smoothTime = 0.3; private var thisTransform : Transform; private var velocity : Vector2;

function Start() { thisTransform = transform; }

function LateUpdate() { thisTransform.position.x = Mathf.SmoothDamp( thisTransform.position.x, target.position.x, velocity.x, smoothTime); thisTransform.position.y = Mathf.SmoothDamp( thisTransform.position.y, target.position.y, velocity.y, smoothTime); }

The target is set to a gameobject containing all the objects used for hte UFO.

What could be happening?

Thanks in advance for your help, Juan.

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
0

Answer by AngryOldMan · Mar 18, 2011 at 05:06 PM

parent the camera to the object manually in the hierarchy. Don't attach the script.

Comment
Add comment · Show 5 · 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 Juancito · Mar 18, 2011 at 05:35 PM 0
Share

hmm sorry I don't understand, how do I parent the camera to the gameobject? Please consider tha what I try to achieve is some smooth camera but with a little delay on the movement.

avatar image AngryOldMan · Mar 18, 2011 at 08:53 PM 0
Share

Ah i see. You don't want to parent the camera you want to change function LateUpdate to function Update and see if that serves you any better. Also add a definable background so you can understand if it's the game that is glitchy/dropping frames or if it's just the way your camera is acting. Then try altering your variables (or atleast watching them through a different variable for the private var velocity)

avatar image Bampf · Mar 18, 2011 at 09:38 PM 0
Share

Juancito, it is common for "camera follow" scripts to be run in LateUpdate. It guarantees that the camera will update its status after all other objects have moved. Is there a specific reason you suggest moving it into Update?

avatar image Bampf · Mar 18, 2011 at 09:39 PM 0
Share

Juancito's other suggestion is a good one. I found it hard to interpret the camera movement in the video without a background for reference.

avatar image AngryOldMan · Mar 18, 2011 at 10:21 PM 0
Share

if you look that's my other suggestion. Fair play with the LateUpdate function though was just a suggestion if it was the game dropping frames, in order to keep the camera updating along with everything else!

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

No one has followed this question yet.

Related Questions

2D Camera Smooth follow, FixedUpdate and LateUpdate odd difference, help needed. 1 Answer

Isometric - Camera follow an object when at the edge of the screen 1 Answer

2D Diablo style movement 1 Answer

How to Manually Move the Camera Horizontally or Vertically? (2D, Parallax), 0 Answers

2d Top Down Camera Movement Causes Tiles and Other Sprites to Blur\Ghost\Jitter 3 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