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 Lairinus · May 07, 2013 at 06:33 AM · c#rigidbodycollidervector3gravity

Vector3 is always subject to serious stutter in Translation

Hello,

Regardless if it's the Rigidbody gravity straight from unity, or my own scripted gravity, there's always a bit of stutter.

My current code is : void translateUnit() {

             if (gravity.isGrounded) //If the unit is grounded
             {
                 Ray ray = new Ray(transform.position,Vector3.forward); //Make a ray shoot foward **Change Eventually**
                 RaycastHit hit;
                 if (!Physics.Raycast (ray, out hit, _groundedRayDistance)) //Cast the ray in the movement direction
                 {    
                     parent.parentObject.transform.Translate((_movementVector ) * 2); //Move if there wasn't a hit
                 }
                 else
                 {
                 }
             }
             else
             {
                 _movementVector.y = gravity.gravity;
                 parent.parentObject.transform.Translate(_movementVector);
             }
     }

Gravity is set to 9.81 for the time being. The problem that if I move in any direction while falling straight down, my character goes down for one frame, and then in the direction for the next frame, and then down again, and then in the direction again.

I thought by merging all of the Vector3s together into one simple movement direction it would fix this issue.

Moreover: My input is in Update() in another controller script, and this is in FixedUpdate.

I've added Coroutines to slow down my grounded and gravity calculation as well, but they didn't do anything except slow down the recognition of grounded and gravity / sometimes exacerbate the problem.

Also, I'm using my own character controller script; just the gravity that's pretty ridiculous to get down.

Thanks for any help!

Comment
Add comment · Show 5
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 Rabwin · May 07, 2013 at 06:37 AM 1
Share

This may or may not be the issue, but I believe FixedUpdate() should be used only for physics calculations so if you're moving your controller in this function, it will definetly stutter. Try placing your controller in Update() and multiply the movement by Time.deltaTime.

avatar image idotal Rabwin · Jan 25, 2016 at 04:38 AM 0
Share

Rabwin- thank you! I didn't realize this has been the problem in my project. CharacterController related adjustments should be in Update and not FixedUpdate... of course!

avatar image Lairinus · May 07, 2013 at 06:45 AM 0
Share

Thanks for the suggestion.

I just changed it and it's the same exact problem, though.

Since I have a rigidbody attached to my unit I figured that I would have to use LateUpdate, but then I read somewhere that for the type of calculation I was trying to do FixedUpdate -might- be better. Then I removed the rigidbody and put it in the Fixed and Late with the same problems.

No matter where I put the method it always stutters.

avatar image Rabwin · May 07, 2013 at 09:13 AM 1
Share

On the rigidbody, try setting it to Interpolation (this should always be used on bodies that have a camera attached, afaik)

avatar image Lairinus · May 07, 2013 at 01:26 PM 0
Share

I set it to both interpolate and extrapolate and re-assigned the method to fixed late and update. The only thing that happened was Extrapolate was very stuttered.

If you guys know of any solutions please post them, but at the moment I'm going to spend a few hours/days building up my Rigidbody script. I have no "air" lag with my smooth jump algorithm, so I'm going to try to extend that to go along with falling off of smallish objects. If it works out I'll post the scripts in a project, as this is a recurring problem for a lot of people it seems.

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

15 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

Related Questions

Raycast not working on object without gravity 0 Answers

Issue using wheelColliders around sphere 1 Answer

Move left etc. according to where player faces 1 Answer

Colliding without gravity 2 Answers

C# if(Physics2D.CircleCast();) Not Returning True 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