Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Tanoshimi2000 · Sep 16, 2018 at 08:39 PM · physicsrigidbodygravity

Gravity slow descent after jump

Basically my character jumps to the correct height, then slowly floats down until/unless I move them, then gravity resumes normally. I can't jump straight up and down without slow descent.

Tried AddForce and velocity. Both work for the jump, but both slow the descent unless I move.

     public void LeaveGround()
     {
         // Add physics to the jump
         RB.AddForce(transform.up * JumpHeight * 2f, ForceMode.Impulse);
     }
Comment
Add comment · Show 7
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 Kaskorian · Sep 16, 2018 at 11:13 PM 0
Share

First some basic questions. $$anonymous$$aybe there is already the error or we can rule it out and conclude on more complex mistakes/errors.

  1. Is there just this one line of code where you apply force to the object or change the velocity, or does your code contain any other behavioral elements?

  2. Have any changes been made in your Physics or Physics2D settings or are there any settings that you find strange? If so, then maybe add to the question (as a screen).

  3. (very unlikely) It may come to a bug because you are working with the local coordinate system and not with for example Vector3.Up.

avatar image Tanoshimi2000 · Sep 17, 2018 at 12:02 PM 0
Share

@$$anonymous$$askorian Thanks for the response. I do have one other section where movement is applied based upon the input. // read inputs float h = CrossPlatformInput$$anonymous$$anager.GetAxis("Horizontal"); float v = CrossPlatformInput$$anonymous$$anager.GetAxis("Vertical"); bool crouch = Input.Get$$anonymous$$ey($$anonymous$$eyCode.C);

         // Update animation
         // update the animator parameters
         m_Animator.SetFloat("Forward", (v * RunSpeed) + (h * TurnSpeed), 0.1f, Time.deltaTime);
         m_Animator.SetFloat("Turn", h, 0.1f, Time.deltaTime);
         m_Animator.SetBool("OnGround", true); // m_IsGrounded
         m_Animator.SetFloat("Jump", RB.velocity.y);
 
         // $$anonymous$$ove the character
             transform.Rotate(0, h * TurnSpeed, 0);
             RB.AddForce(transform.forward * v * RunSpeed, Force$$anonymous$$ode.Impulse);
         

Incidentally, I'm able to watch the Velocity.y value, and it goes positive on the way up, negative during correct speed fall, but then hits zero and the descent slows.

No other changes to Physics in the code or editor.

When it's falling slow, if I move or rotate, then gravity resumes normally. I took out the on_ground checks so that I could do that, rather than waiting a $$anonymous$$ute for touchdown.

avatar image Kaskorian · Sep 17, 2018 at 01:34 PM 0
Share

Okay next, just to imagine: how exactly does the jump go? I'm just trying to reproduce the mistake. When I use your LeaveGround method, the jump works normally.

So how exactly does he work for you? You mean your object jumps normally but falls too slowly. If this already occurs at the highest point, so jump up to JumpHeight -> velocity.y approaches 0 -> At the highest point velocity.y = 0. Does the error occur from there on? Is the fall speed just lower than it should be or is it something more special. You mean the value is negative when falling down, as it should be, until it reaches 0. At which point in time or at which point velocity.y reaches a value of 0 as well as at the highest point.

avatar image Tanoshimi2000 Kaskorian · Sep 17, 2018 at 01:43 PM 0
Share

So there's a animation burned into the jump. To that, I add extra force to get him higher. He goes all the way up, as expected, then comes down a little bit at normal speed, most likely from the animation, then it slows down to a floating descent. It remains that slow, unless I move forward or rotate, so it almost looks like it's standing on a platform and then falls off when you move forward, except that it is still falling, just more slowly.

Stepping out. Will be back this evening. Thanks for taking the time.

avatar image Kaskorian Kaskorian · Sep 17, 2018 at 02:12 PM 0
Share

Just an idea.

Could I be that there is a root motion applied to the jump Animation, which is moving up your object also when is falls down. To check if so, just uncheck "Apply Root motion" in the animator inspector.

Here a tutorial for root motion:

Also, is the Animation in place? So if you look at your Animation file in the inspector, is the object moving away from it's start Position (Animation preview window). The Problem could be that there is a root moving Vector applied to the Animation, which moves the object upwards. If thats the case this should explain why the object falls down normally after you move and rotate because then another animation is active and no upward movement occurs

avatar image Tanoshimi2000 Kaskorian · Sep 17, 2018 at 11:48 PM 0
Share

@$$anonymous$$askorian Here's what it looks like. https://www.ctacinvestigations.com/gravity.avi

The Forward value is vertical input * Speed. The Jump value is the Rigidbody.velocity.y.

Show more comments

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

175 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 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

Why my gravity direction is rotating with transform.rotation? 1 Answer

Rigidbody doesn't seem to apply gravity 1 Answer

Adding Gravity to a game object to make a black hole sucking effect. 1 Answer

Space,Gravity,RigidBody,Physics Forces 0 Answers

Order of execution: AddForce, rigidbody movement, velocity update? 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