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 Leroterr · Feb 15, 2015 at 11:27 AM · movementtransformpositionlagstutter

Intense Lag/Stutter when 3d cube is moving.

Why does it lag/stutter so much when I'm moving my 3d cube downwards? It's just a simple 3d cube. I've also tried FixedUpdate and Update but I prefer FixedUpdate since in Update, its speed changes drastically depending on the lag, while in FixedUpdate, the speed is constant, but the lag is much greater.

This is the code I'm using right now. Is there something in it that's making my cube lag? My scene only contains a cube and a light, and while it doesn't lag that much on my desktop, it lags really hard on my Samsung Galaxy:

 using UnityEngine;
 using System.Collections;
 
 public class fall : MonoBehaviour {
 
     public static float speed;
 
     Vector3 move;
     
     void Awake () {
         
         move = new Vector3(0, -9.0f, 0);
 
         speed = 4.0f;
         
     }
 
     // Update is called once per frame
     void FixedUpdate () {
     
             move = new Vector3(transform.position.x, -9.0f, transform.position.z);
             transform.position = Vector3.MoveTowards(transform.position, move, Time.smoothDeltaTime * speed);
 
         }
 
     }
 
 }
 

I've also tried Rigidbody.MovePosition and Transform.Translate, but it still lags very hard.

Comment
Add comment · Show 3
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 einWikinger · Feb 15, 2015 at 11:42 AM 0
Share

Do you have a rigid body on the game object? If yes, remove it if you don't make use of rigid body simulation for the object. If you need it somehow, make the RB kinematic so it won't be influenced by the simulation. Another reason could be that your rendering frame rate and simulation frame rate are different. Then you could try to enable interpolation/extrapolation on the rigid body or move the translation code into Update() ins$$anonymous$$d of FixedUpdate().

avatar image Leroterr · Feb 15, 2015 at 11:55 AM 0
Share

Yeah I do, I need it though, so I'll try setting it to $$anonymous$$inematic. Thanks!

EDIT: It still lags, even with the rigidbody removed.

I also have the same exact problem as this guy: http://answers.unity3d.com/questions/709900/movement-in-unity-is-lagging-every-few-seconds-or.html

avatar image meat5000 ♦ · Feb 15, 2015 at 03:32 PM 0
Share

Use Update, not FixedUpdate.

Time.deltaTime should be smooth enough.

I had a situation once where I though a character was bobbing around frantically. It actually turned out that the character was smooth as silk and it was the camera which was bobbing.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by hexagonius · Feb 15, 2015 at 03:30 PM

There's two ways to get smoothed visuals:

Always use Rigidbodies on GameObjects that move. Everything else is considered static and expensive when moved anyway.

  • Manipulate your Transforms in Update() since it's frame based and make the Rigidbody kinematic. You won't get proper collision though.

  • Manipulate your velocity in FixedUpdate() and use interpolation mode on your Rigidbody component without being kinematic. Since FixedUpdate() is a different loop than Update and the Rigidbody needs to get a chance to know where it's going to be during a render call, it can only predict that when it has a velocity.

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

22 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

2D Background Stop Moving on BoundingBox Exit? 2 Answers

Setting target position in Vector3.MoveTowards 2 Answers

how can do click then move on a gameobject? 1 Answer

Move object with finger swipe 0 Answers

follow along the XZ plane? 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