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

Physics documentation should teach users to set parameters before adding nodes #45638

Closed
Tracked by #45334 ...
pouleyKetchoupp opened this issue Feb 1, 2021 · 6 comments · Fixed by godotengine/godot-docs#6183

Comments

@pouleyKetchoupp
Copy link
Contributor

Godot version:
3.2.3

OS/device including version:
Windows 10

Issue description:
Based on #45598.
This issue is Bullet specific, but it's generally better to set physics objects parameters before adding them to the simulation in order to get the best performance.

Documentation and tutorials should reflect that so new users can be taught good practice, but it's not the case at the moment.

Example where bad practice is shown as an example:
https://docs.godotengine.org/en/stable/getting_started/step_by_step/your_first_game.html#main-script

There might be more examples of this, so it would be good to make a pass on checking tutorials related to physics. Documentation could also mention it somewhere, but I don't know if there is already a good place for this information.

Steps to reproduce:
n/a

Minimal reproduction project:
n/a

@Xrayez
Copy link
Contributor

Xrayez commented Feb 1, 2021

What about setting global_position? Physics nodes must be inside the scene tree to modify the properties related to global transform. Not all nodes are added to root node, setting position might not yield expected result, so that's where I find setting global_position to be a universal solution, but I wonder whether there are other ways to do this.

@pouleyKetchoupp
Copy link
Contributor Author

@Xrayez If you really need to, you can set the transform after adding objects, but you just won't get the best performance. So I guess the message documentation can teach is "set parameters before adding objects whenever possible".

That said, one way to handle this scenario would be to add a property to disable physics on physics nodes, so that you would have a way to disable physics, add to tree, set everything you need, and then enable physics again to add it to the physics world. I don't think it would be complicated to implement, but it's a bit outside this issue's scope and it would need a proposal.

@Zireael07
Copy link
Contributor

IMHO the property trick isn't needed, but I'm thinking the workaround of "disable-add-set-reenable physics" could be documented?

@akien-mga
Copy link
Member

IMHO the property trick isn't needed, but I'm thinking the workaround of "disable-add-set-reenable physics" could be documented?

Well the "property trick" is needed to perform that workaround. You can't disable physics on a per-node basis as of now.

@Zireael07
Copy link
Contributor

You can set collision shapes to disabled, I thought that's what they meant.

@pouleyKetchoupp
Copy link
Contributor Author

@Zireael07 I guess you can disable shapes to work around performance problems in this scenario but it's a bit hacky (in this case the physics body is still simulated but it collides with nothing). This trick should generally work ok, but it's difficult to predict what undesirable side effects it might have in some situations, since e.g gravity and forces would be still applied.

I meant to add a way to globally disable physics on an object, which you can't do at the moment and might be useful in other scenarios as well. It would be much clearer and well documented because it would have no possible side effect in physics.

rburing added a commit to rburing/godot-3d-dodge-the-creeps that referenced this issue Mar 13, 2022
rburing added a commit to rburing/godot-3d-dodge-the-creeps that referenced this issue Mar 13, 2022
rburing added a commit to rburing/godot-docs that referenced this issue Mar 13, 2022
…ng it to the scene tree

This follows the recommendation from godotengine/godot#45638
rburing added a commit to rburing/godot-docs that referenced this issue Mar 13, 2022
…ng it to the scene tree

This follows the recommendation from godotengine/godot#45638
rburing added a commit to rburing/godot-docs that referenced this issue Mar 13, 2022
…ng it to the scene tree

This follows the recommendation from godotengine/godot#45638
akien-mga pushed a commit to godotengine/godot-docs that referenced this issue Apr 29, 2022
…ng it to the scene tree

This follows the recommendation from godotengine/godot#45638

(cherry picked from commit 3f0e91a)
@akien-mga akien-mga added this to the 3.6 milestone Oct 5, 2022
rsubtil pushed a commit to rsubtil/godot-docs that referenced this issue Apr 11, 2023
…ng it to the scene tree

This follows the recommendation from godotengine/godot#45638
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