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

[Bullet] Area Gravity issue #32776

Closed
Tracked by #45022
mrjustaguy opened this issue Oct 12, 2019 · 4 comments · Fixed by #42374
Closed
Tracked by #45022

[Bullet] Area Gravity issue #32776

mrjustaguy opened this issue Oct 12, 2019 · 4 comments · Fixed by #42374

Comments

@mrjustaguy
Copy link
Contributor

mrjustaguy commented Oct 12, 2019

Godot version:
Godot 3.2 Alpha Official, Godot 3.1.1 stable also

OS/device including version:
Windows 10

Issue description:
Short desc:
Gravity Vec property of area applies changes fine in the editor, but when changed with code it has no effect on the Gravity

Long desc:
Changing Gravity Vec at runtime (using code ofc) fails to change the orientation of the gravity, however doing the exact same change in the scene before running and changing the gravity option works just fine, Space Override is at Replace, project settings gravity has been set to 0,0,0, and the test scene has the standard gravity of -1 on y axis set on the area (Gravity Vec in inspector of said area), and in code when action ui_up is pressed the code changes the 0,-1,0 value of the vector 3 to 0,0,-1, and takes a reading of the value of Gravity Vec before and after, showing that it Did indeed change it, however instead of the test sphere falling in the direction that it should for the new gravity vector, it keeps falling with the same vector as before.

Note: Area2D works just Fine

Steps to reproduce:

  1. Create an Area, give it a sizable collision shape, set Space Override to any that isn't disable (use set project setting default gravity to 0,0,0 or use replace in the override in the area inspector)
  2. Create a RigidBody inside the area, made to fall in the Area's Gravity Vec property direction and speed
  3. Set Area's Gravity Vec to some value (0,-1,0 for example)
  4. Make Code for the Area so that when you press a button (like up arrow) the Gravity Vec changes to some other value (like 0,0,-1), printing values before and after to make sure that there is a change in the Area's Gravity Vec Property
  5. Observe how the code failed to have an impact on the movement of the RigidBody
  6. Change the Gravity Vec property in the editor to the value you want to change it to in the code
  7. Observe how the RigidBody is moving now (no longer going in the direction set in the original run the way it was going before code, and going the way it should have changed to after the code executed)

Minimal reproduction project:
Project.zip

Please note: In the Project above the Spatial Scene is the one where the code test is, other scene is exactly the same except for the change in the Area's Gravity Vec in the inspector from 0,-1,0 to 0,0,-1 which causes the code to be useless in that scene as it is set to change the Gravity Vec of the area to 0,0,-1 which in that scene it already is

@mrjustaguy
Copy link
Contributor Author

After some more testing, I think I know exactly why it happens, I've made 2 collision boxes, and i left some room between them, and when the 1st one was left by the gravity that has been set in the editor's area (pre code manipulation) i pressed the button to switch the Gravity Vector and when it entered the 2nd Collision under the area it worked fine, which means that it probably needs to re-register the bodies in the area for the new Gravity Vec to work on said bodies.

@mrjustaguy
Copy link
Contributor Author

mrjustaguy commented Oct 16, 2019

Area Project.zip
This is an example of what is happening and why

  1. Ui_up changes the gravity vector to 0,0,-1
  2. Ui_end sets the rigid body above the area, it falls down to the area with time (NOTE: If it didn't hit the collision and hit fullstop, as the fall down is thanks to the remaining linear velocity of the rigid body from the gravity that stopped affecting the body after it was teleported out of the area)
  3. If Ui_up is pressed before the body enters, the body will have the proper area's gravity
  4. if Ui_up is pressed after/while the body is inside, it will have no effect on the body inside
    Probable cause: Gravity Vec (area property) is only sent to the bodies that enter, and isn't sen't to the bodies already inside, which they should be

@bojidar-bg
Copy link
Contributor

Seems like an issue with Bullet, since I cannot reproduce it under GodotPhysics. CC @AndreaCatania.

Probably, there has to be a loop calling scratch_space_override_modificator on every item in overlappingObjects around here:

set_spOv_gravityVec(p_value);

@mrjustaguy
Copy link
Contributor Author

Affirmative problem is in Bullet physics that is used by default, GodotPhysics works fine as it should.

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

Successfully merging a pull request may close this issue.

4 participants