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
1
Question by $$anonymous$$ · Sep 07, 2013 at 07:24 PM · c#movementphysicsrigidbodyfps

RigidBody.MovePosition seems jerky in movement

Hey everyone,

So my goal is to make my own FPS controller so I have more control over exactly how I want the feel of movement to be.

The FPS controller must be influenced by physics, and also in a more realistic way. This means that if you walk along and bump into an object heavier than the FPS controller, that object must be hard to push aside, etc.

Now here's the problem.

I've found that using a rigid body with the RigidBody.MovePosition method gives me exactly what I want. I can move around in a fast-paced manner (not having to deal with slower controls by using AddForce etc, since this would also cause acceleration and feel not quite as accurate to the player), and bumping into other physical objects cause the player to slow down when those other objects are heavy. This is all perfect.

The only problem that I'm having is that the movement feels very jerky and not smooth at all. I read around a bit on found out this guy had the same problem: Official Unity3D Forum Thread

The problem is, the answer provided by AngryAnt of moving the movement code to "Update" instead of "FixedUpdate" for smooth movement simply doesn't seem to work. The movement is still as jerky as it was before. What fixes this is by upping the Fixed time step interval of the physics engine, but I feel this is no good solution at all to a simple character movement problem.

My Question

My question then is, how do I get to have full control over my rigid body to provide smooth and very reactive controls, whilst also being affect by physics realistically? MovePosition does almost all of this, except the smooth movement, which is a bummer. Am I doing something wrong?

Setting the rigidbody to kinematic isn't really that awesome, because it can simply push anything out of the way no matter what mass they have, etc.

My Code

     // Update is called once per frame
     void Update() 
     {
         if (Input.GetKey(KeyCode.W))
         {
             rigidbody.MovePosition(new Vector3(rigidbody.position.x,
                                                rigidbody.position.y,
                                                rigidbody.position.z + forwardMovementSpeed * Time.deltaTime));
         }
         
         if (Input.GetKey(KeyCode.S))
         {
             rigidbody.MovePosition(new Vector3(rigidbody.position.x,
                                                rigidbody.position.y,
                                                rigidbody.position.z - backwardMovementSpeed * Time.deltaTime));            
         }
         
         if (Input.GetKey(KeyCode.A))
         {
             rigidbody.MovePosition(new Vector3(rigidbody.position.x - sidewaysMovementSpeed * Time.deltaTime,
                                                rigidbody.position.y,
                                                rigidbody.position.z));    
         }
         
         if (Input.GetKey(KeyCode.D))
         {
             rigidbody.MovePosition(new Vector3(rigidbody.position.x + sidewaysMovementSpeed * Time.deltaTime,
                                                rigidbody.position.y,
                                                rigidbody.position.z));    
         }
         
         if (Input.GetKey(KeyCode.Space))
         {
             
         }
     }

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

0 Replies

· Add your reply
  • Sort: 

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

14 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

Related Questions

RigidBody immediately stops after AddForce 1 Answer

Interpolate problem? Jump isn't smooth... 1 Answer

Force to Velocity scaling? 2 Answers

Sometimes the ball isn't moving 0 Answers

Making a bubble level (not a game but work tool) 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