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
3
Question by KEric · Mar 12, 2014 at 10:44 AM · cameraphysicsparticleslagfixedupdate

Particles lag/stutter - choppy movement

Here's the problem. In my game I have a moveable player which has a rigidbody attached. The position as well as it's velocity is controlled in the script via simple assignment (rigidbody.position += etc). Now, the camera movement is based on player's position as well as it's velocity (it zoom out when the player goes faster and position itself respectively to it's speed and position). Of course because the camera's adjustments are based on the rigidbody I had the common problem of the world/cameras's jerkiness. Based on what's manual says and through pure logic I decided to put all the camera's adjustment code into FixedUpdate function and that did the trick.
Finally, the matter from the question... having my camera and player moving exceptionally smoothly I've noticed that the particles from my particle systems (instantiated dynamically) had a choppy movement... Unfortunately, because my knowledge wasn't sufficient I spent some time on it, trying to find something on the internet, but in vain. Then it struck me, as I've already had similar problem and a solution sufficed, I've moved particles simulation to FixedUpdate as well (code below), and voila, it started to work.
And of course the question: is it a good practice having my particles update functionality moved to FixedUpdate and if not, what's the best solution for the situation described above?

 using UnityEngine;
 using System.Collections;
 
 public class FixedTimeParticleSystem : MonoBehaviour {
     
     private ParticleSystem ps;
     private bool playing = false;
 
     private void Awake() {    
         ps = GetComponent<ParticleSystem>();
     }
 
     public void Restart() {
         ps.Simulate(0.0f, true, true);
         playing = true;
     }
 
     public void Stop() {
         playing = false;
     }
 
     void FixedUpdate() {
         if(playing)
             ps.Simulate(Time.fixedDeltaTime, true, false);
     }
     
 }
 
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 Pawl · Nov 07, 2014 at 10:10 PM 0
Share

Brilliant!

Two and a half years later and I have done exactly as you described (building a third-person adventure game with custom player movement in FixedUpdate, requiring the camera to also use FixedUpdate) and I was experiencing Shuriken particle stutter (Unity 4.5.1f3).

Your script has immediately resolved the issue. I must say, I would have never thought of calling ps.Simulate() manually from within FixedUpdate. $$anonymous$$uch thanks!

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by KEric · Jul 27, 2017 at 08:59 AM

I think the problem was with the scale of the game world which was very small. When I've tested the gameplay with values of physics and rendering threads slowed down significantly (Time.timeScale, Time.fixedDeltaTime values) the choppy movement disappeared.

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
1

Answer by tayloreichhorst · Jun 11, 2015 at 09:58 PM

I know this is an old topic.. I was wondering, KEric, can you post the code you used to get your camera to follow smoothly so that the world isn't jerky around it? I am having that issue right now and I am pulling my hair out! I like my hair...

I have tried putting it into fixedupdate, but haven't had much luck, I wouldn't mind seeing if you're doing something that I'm missing.

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 pet1100 · Mar 16, 2017 at 08:34 PM

Remove simulation and use play/stop/clear instead. If possible add your particle system to an empty object and put it as a child of the camera (this will keep it at the same distance all the time). Particle system API you should take a loot at it. ;) https://docs.unity3d.com/ScriptReference/ParticleSystem.html

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

23 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

Related Questions

Physics + first person camera = jitter? 4 Answers

Weird MoveTowards behaviour on low fps only. 0 Answers

Unity render lag questions 1 Answer

Does AddForce use Time.deltaTime or TIme.fixedDeltaTime or it depends on whether it is being used in Update() or fixedUpdate()? 2 Answers

Particle System 2D dont works in Game 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