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 Chimera3D · Oct 14, 2012 at 11:25 PM · cameramovementpositionlerpsmooth

Smooth Camera/Object Movement

So what I have is an orthographic camera that smoothly follows an object by "lerp-ing" to its position, however the object follows the cursor, by sending a raycast from the camera onto the screen. It all works but the object jitters while following the cursor, this is because since the camera is always moving itself, the cursor and subsequently the raycast are both always moving. I'm sure this is the cause because I ran a test with a camera that statically follows the object and it works well. I've already tried making another camera that statically follows the object for the raycast and one that "lerps". This doesn't work because the game gets confused as to which camera should be used for each task. Anyone have any ideas of how I can fix this "jittery" problem?

I'm not going to post the entire code because it's very long but here's the important part, newPos is just the position of the object, cam speed is just the speed of the camera, here we are changing the position of the camera with the "transform.position = " part, the code directly below is for the camera:

 transform.position = Vector3.Lerp(transform.position, newPos, camSpeed * Time.deltaTime);

This is what I'm using to move the object, this works perfectly, but the camera movement is making it jitter.

 var mousePos = Input.mousePosition;
         
 movePosition = Camera.main.ScreenToWorldPoint (Vector3 (mousePos.x, mousePos.y, 1));
         
 var moveDir = movePosition - transform.position;
             
 var distance = Vector3.Distance (transform.position, movePosition);
     
 rigidbody.AddForce (moveDir.normalized * speed);
 rigidbody.drag = distance +3;
Comment
Add comment · Show 2
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 T27M · Oct 14, 2012 at 11:30 PM 0
Share

Post your code.

avatar image Chimera3D · Oct 17, 2012 at 05:45 AM 0
Share

Is there any way I can do this?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by sparkzbarca · Oct 15, 2012 at 01:01 AM

why is the camera lerping?

Im just saying the camera is following the object the object is lerping. the camera seems like it should just stay a set distance from the object and since its paired to a lerping object its movement will look smooth because the objects is smoothed

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 Chimera3D · Oct 15, 2012 at 02:26 AM 0
Share

No, the first line of code is part of the camera's code. Sorry, should've clarified that.

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

12 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

Related Questions

How to smooth my camera (Vector3.Lerp) 0 Answers

Problems with Lerp. 1 Answer

Move A Camera Between Two Points Smoothly 1 Answer

How to smoothen movement of a child object? 1 Answer

Camera Stutter During Distance Correction 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