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 /
avatar image
0
Question by Jason Hamilton · Jun 18, 2011 at 11:13 AM · rigidbodyvelocityfallingy-axis

Check if rigidbody is falling

Hey, Im trying to get my rigidbody to stop its code when it is falling, so i tried an if rigidbody.velocity.y is != to 0, this did work in checking if the player is falling or not, but then my other code could kick in. In the code it used rigidbody velocity to move left and right, NOT up and down, but this still trips the if velocity.y statement. how do I get around this?

Comment
Add comment · Show 3
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 Jesse Anders · Jun 18, 2011 at 03:40 PM 1
Share

I'm not sure if I follow your question, but it sounds like you might need to use a threshold value and a < comparison, e.g. 'if (velocity.y < fall_threshold)', where 'fall_threshold' is a negative value. This way, slight variations in the y velocity (e.g. due to numerical error) won't be registered as 'falling'.

avatar image Jason Hamilton · Jun 19, 2011 at 07:50 AM 0
Share

Thats what I know how to do, the real problem is the velocity.y is influenced by moving the rigid-body on the x axis?

avatar image RodrigoSeVeN · Jun 19, 2011 at 08:16 AM 0
Share

I would say that the friction on the rigidbody causes some slight changes on the y axis of it's velocity. If this means you are getting small fragments in there, you will indeed need to check for something like Jesse said, as the falling velocity will be a negative value.

3 Replies

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

Answer by Jason Hamilton · Jun 25, 2011 at 04:37 AM

I dont know how I this works but I moved my 'check the rigidbody y velocity' if statement to a late update and it works fine! maybe because it is called after the move velocity? :)

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 Dreamblur · Jun 25, 2011 at 05:01 AM 0
Share

LateUpdate() is called neither before nor after physics simulation. LateUpdate() happens after Update() within the course of a single frame. Physics simulation, on the other hand, occurs after every interval of Time.fixedDeltaTime.

avatar image
0

Answer by RickshawDerpyDerp · Jul 16, 2019 at 11:48 AM

Isn't working for me. All I am testing at this point is

 print(rb.velocity.y < 0);

And my debugger spits out nothing but "false", "false", "false", "false",... whether I put it in Update(), LateUpdate() or FixedUpdate() and jump around. Absolutely ridiculous.

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 the1whom0x · Mar 29, 2020 at 05:17 PM

I'm late to the party but, comparing floats with != and == is not accurate.

Using Mathf.Approximately(float1, float2) is much better, and would fix your issues.

@RickshawDerpyDerp

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to make gameobjects fall down faster with each update ? 1 Answer

Rigidbody y velocity is stuck on 0, gravity is not turned off. 2 Answers

Detect when falling 1 Answer

Velocity powered rigidbody on a moving platform without parenting. 3 Answers

Velocity for movement 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