Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Wil245 · Jan 10, 2019 at 09:11 PM · rigidbodyaddforcestutterjitteringjerky

rigidbody addforce jittering

Please tell me what I am doing wrong, I have a simple scene with a floor, a static camera and a sphere with a Rigidbody, the movement is horrible, I have tried all the solutions I could find, interpolate, modify the FixedTimeStep, etc, etc, etc.

I understand that FixedUpdate runs by default 50 times per second, everyone explains it, but no one says how to move an object with physics smoothly, they just come to the conclusion: "Now it does not tremble so much ... it's fine for me ... ". It can not be that hard...

 using UnityEngine;
 
 [RequireComponent (typeof(Rigidbody) )]
 public class PlayerController : MonoBehaviour
 {
 
     Rigidbody rb;
 
     Vector3 movement;
 
     public float SpeedMultiplier = 5f;
 
     private void Awake()
     {
         rb = GetComponent<Rigidbody>();
     }
 
     void Update()
     {
         movement.x = Input.GetAxis("Horizontal");
         movement.z = Input.GetAxis("Vertical");
     }
 
     private void FixedUpdate()
     {
         MoveWithForce();
     }
 
     private void MoveWithForce()
     {
 
         rb.AddForce(movement * SpeedMultiplier);
 
     }
 
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

4 Replies

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

Answer by Wil245 · Jan 28, 2019 at 04:57 PM

Well, after losing so much time with the subject, I discovered that the flaw is in the editor, in the final construction it works excellent. I thought I could not be so wrong with such a simple set of instructions ... It would be necessary to see how to report the inconvenience.

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 RadonRaph · Jan 10, 2019 at 10:45 PM

Hello ! Why you want to execute the deplacement in the FixedUpdate() and not in the Update ? it will run more smoother in the update() because its call more often. Raph

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 Okido · Oct 10, 2020 at 12:04 PM 0
Share

It will not run more smoothly in Update - quite the opposite. Fixed update is consistent, and should always be used when interfering with an object's physics. Update is called every frame, meaning physics behaviour will change on a good vs a poor machine, or during a framerate dip

avatar image
0

Answer by Kudorado · Jan 11, 2019 at 03:14 AM

Trying change

  rb.AddForce(movement * SpeedMultiplier);

to

   rb.velocity = (movement * SpeedMultiplier);

it will run smoothly cause there is no affect by mass and acceleration.

Reference: https://answers.unity.com/questions/359133/why-use-addforce-rather-than-modify-velocity.html

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 Wil245 · Jan 11, 2019 at 09:59 PM 0
Share

I need to use Force, but even working on Velocity the movement is jitter...

avatar image
0

Answer by Wil245 · Jan 11, 2019 at 01:34 PM

Hello, thanks for answering. The problem is that the direct modification of Velocity does not have the same behavior, I need Force for the calculation with the mass, with respect to putting the code in Update, according to the documentation, the physics must be handled in FixedUpdate to avoid strange behaviors, and it is true, if I do it in Update and the frame rate varies, the player crosses objects, and irregular movements of teleportation are produced... I also do not understand why you say that Update will be called more frequently, maybe I understand wrong...

Need to know how to use Addforce correctly...

Comment
Add comment · Show 2 · 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 RadonRaph · Jan 11, 2019 at 02:23 PM 0
Share

Do you use a physics material ? try using a physic material without friction ?

avatar image Wil245 RadonRaph · Jan 11, 2019 at 09:48 PM 0
Share

I have tried with and without physical material, but the problem persists.

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

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

Related Questions

Method for giving a ball momentum through a swipe 0 Answers

Speed of the flying projectile (using forces) 1 Answer

Game engine stuttering 1 Answer

Rigidbody.Addforce not working in Unity 5.4.1 3 Answers

AddForce and AddRelativeForce not forcing in the right directions 2 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