Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gravity is suddenly default "on" only if ExternalForce is used, but default off otherwise #526

Open
aDecoy opened this issue Oct 3, 2024 · 0 comments

Comments

@aDecoy
Copy link

aDecoy commented Oct 3, 2024

Hi, this is a confusing non intuitive change in default behaviour that showes up if one updates ExternalForces, and I feel like it is a bug.

How i found the strange behaviour/maybe-bug

I had commented out // .insert_resource(Gravity(Vector::NEG_Y * 9.81 * 100.0)), but my blocks were still falling down. Very confusing.
It stoped falling down if i never updated ExternalForce. If i used myForceFromQuery.apply_force(Vector::ZERO);, it would start to fall again. I thought it might be something wrong with the forces.

After printing stuff in avian2d-0.1.2/src/dynamics/integrator/mod.rs:214, i learned that it uses the default 9.81 gravity. Indeed, if i spesificly set gravity to zero, then this behaviour is gone. .insert_resource(Gravity::ZERO).

It is very confusing that gravity is default off, but suddenly becomes default earth-gravity if I update the ExternalForces.
It might be that it internally always is default -9.81, but never used unless one starts to use ExternalForces. I dont know, but it was confusing

What i suggest should change:

Gravity should have the same default for Entities, with and without updates to ExternalForces. (I would preffer off, but as long as it is the same i am ok with it)

Alternativly:

If this is intended behaviour, I feel that we need a note on this in the documentation https://docs.rs/avian2d/latest/avian2d/dynamics/rigid_body/struct.ExternalForce.html

🫡 Thanks for listening

Other than this I am having a great first experience with Avian so far 👍 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant