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 Larry-W · Mar 20, 2015 at 05:10 PM · androidmovementlerpmovement scriptchoppy

Everything is choppy... How can I make object movement more fluid?

Hello,

I'm having problems with making objects move fluidly through my game world.

I've toned it down to an extremely basic situation:

Setup:

5 x planes placed one after another to make a long "field"; All static

1 x cube (basic 3d shape cube)

1 x camera - child of cube

No lights, No shadows cast, no shadows received.

The following extremely simple script is attached to the cube:

 void Update()
 { 
      transform.position = Vector3.Lerp(transform.position, transform.position + transform.forward, Time.deltaTime * 5f);
 }


This causes the cube to move "choppily" through the scene.

Can anyone suggest a way to make this cube move fluidly through the scene?

NOTE: the choppiness is palpable in the editor, and on my target platform (android, galaxy s4 device, 4.4.4) // using unity 5 free

Thank you.

UPDATE:

It seems that the problem is limited to Android platform builds. I tried switching to WebGL, which resulted in full fluidity in both the editor and in Chrome...

I had made a far more complex scene in 4.6 (for a different project), which did not have this choppy movement problem (on Android)... I guess I'll investigate platform specific issues and fixes...

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by tanoshimi · Mar 20, 2015 at 05:11 PM

That's a very peculiar movement code. If you just want to move forward at a rate of 5 units per second, try:

 transform.position += transform.forward * Time.deltaTime * 5f;
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 Larry-W · Mar 20, 2015 at 05:28 PM 0
Share

I thought Lerp worked in a similar (identical) way...

Nonetheless, I tried replacing my line with yours; unfortunately it did not fix my problem... It actually feels (almost) exactly the same...

Thanks though!

avatar image
0

Answer by ForeignGod · Mar 20, 2015 at 05:50 PM

http://docs.unity3d.com/ScriptReference/Vector3.SmoothDamp.html

Try implementing some dampening to your movement code. I wont write the code for you but have a link to the documentation ^^

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 Larry-W · Mar 20, 2015 at 06:17 PM 0
Share

$$anonymous$$ind of has the same effect as "Lerping" the camera's position towards the player... (like in the survival shooter demo)

Unfortunately, it didn't really help; the choppiness is still present.

When looking at the scene view, the cube does indeed seem to exhibit irregular movement...

I don't understand why my original code, or tanoshimi's, doesn't produce perfectly fluid movement... $$anonymous$$athematically, it should; especially considering this ultra-basic scene is running @ ~1000fps...

Anyways, thanks for suggestion!

avatar image
0

Answer by UNZoOM · Mar 20, 2015 at 06:44 PM

Replace update with LateUpdate and see if it works.

"I don't understand why my original code, or tanoshimi's, doesn't produce perfectly fluid movement... Mathematically, it should " You are right , because its not the choppiness in the cube its the choppiness in the camera's perspective.

Making camera a child of the GO ( cube in your case ) is not really a good practice. Trying changing to LateUpdate , if that dosent work well then you should preferably detach the camera and script for following the movement rather.

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

2D Vector Movement,Vectorel Movement with Buttons 2 Answers

Unity Android movement 1 Answer

My vector3 lerp is not working properly 1 Answer

How can I drag a GameObject along a fixed line? 2 Answers

How to move gameobject with touch on Android 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