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 Teyhouse · Jun 09, 2014 at 02:48 PM · 2dspriteperformance

2D movement stutter

Hi,

i have got some performance-trouble while duing a simple task: Moving a single Sprite / Rigidbody2d over the screen. I simply took a two sprites (one for the background and one for the moving object), placed them on the scene and wrote a script to move one of the objects. The Code i used is like this:

 using UnityEngine;
 using System.Collections;
 
 public class move : MonoBehaviour {
 
     Rigidbody2D car;
     private Vector2 speed = new Vector2(10, 0);
 
     // Use this for initialization
     void Start () {
         car = this.rigidbody2D;
     }
     
     // Update is called once per frame
     void FixedUpdate () {
         car.MovePosition(car.position + speed * Time.deltaTime);
     }
 }

The Sprite is stuttering - but why? I made you a video to clarify what i am talking about / attached the project. I would be realy thankful if somebody could check what's going wrong about my projeclink textt. Thank you.

Video: http://www.file-upload.net/download-9031974/Unity-2014-06-09-15-53-09-51.rar.html Project: Attached

Kind regards Teyhouse

sprite.zip (132.3 kB)
Comment
Add comment · Show 1
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 Teyhouse · Jun 11, 2014 at 06:42 PM 0
Share

Hi Guys,

thanks for you response - unfortunately none of them helped. What i have tried:

Set the rigidBody to is$$anonymous$$inematic Set rigidbody.velocity directly ins$$anonymous$$d of using movePosition

This had absolutely no effect on the "stuttering"

Go to the inspector under Rigidbody2D. Select the dropdown for "Interpolate" and set to Interpolate

Done - also no effect still an ugly stuttering effects...

AddForce

Nope, i have tried AddForce (with booth Force$$anonymous$$odes), trasform.translate or setting directly the velocity - everything works or more looks the same way / using or not using time.detlatime does net cause any changes / also using LateUpdate.

If tried my project on 3 PCs and a $$anonymous$$ac - still the same result. So what i am doing wrong? I mean we are talking about a simple step: Placing two Sprites and smoothly moving one of them over the screen. This should be quite simple and smooth. I have got more than enough FPS, so it can't be kind of a performance problem.

So guys before i get crazy to make sure i do not make something wrong: Please can somebody try it himself with the latest Unity-Version 4.5.0f6? Just make a new 2D project - place a sprite and let it move from one site of the Camera to the other-site and look it you also got the stuttering-effect... if your version works pleace show it to me. This problem is getting kind of frustrating.

Thanks everybody

4 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by darthbator · Jun 11, 2014 at 01:00 AM

Fixed update runs at a fixed interval (normally 60 times a second). When you move objects in there you don't need to make them "framerate independent" by muliplying by Time.deltaTime. That might help you at the least.

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 Kiwasi · Jun 11, 2014 at 01:13 AM 0
Share

Its still a good idea to maintain frame rate independence in case you decide to change the fixedTimeStep later.

avatar image
0

Answer by Kiwasi · Jun 11, 2014 at 01:12 AM

The stuttering may occur if collisions are enabled. The physics engine will follow you instructions to move the car. However the car may end up colliding and bounce back after each frame.

Possible solutions

  • Set the rigidBody to isKinematic.

  • Set rigidbody.velocity directly instead of using movePosition

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

Answer by cryingwolf85 · Jun 11, 2014 at 01:17 AM

Go to the inspector under Rigidbody2D. Select the dropdown for "Interpolate" and set to Interpolate.

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

Answer by Miziziziz · Jun 11, 2014 at 01:34 AM

if you're going to use physics, maybe use AddForce rather than Vectors for movement

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

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

Related Questions

How to handle a MASSIVE amount of game objects? 2 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Exploding texture into it's individual pixels 2 Answers

how do i make an object always face the player? 5 Answers

Sprite renderer, bad perfomance on mobile 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