panda3d
panda3d copied to clipboard
Make AI update take time into account
Issue description
Currently, the contrib ai system doesn't take the time between updates into account, which means that ai-powered objects move slower at lower frame rates (and faster at higher ones).
The way facing updated would, if the object was supposed to move more than ~5 meters per update, make the object face backwards to the direction of travel.
Solution description
- Corrects facing to be based off the current position and force direction, instead of the previous position.
- Applies time to velocity/position calculations.
- If a current project is using a fixed 30/60 fps no updates are likely to be required, but outside of that delta-time should be threaded through, and object mass/force updated as appropriate. Frame rates below ~10 fps may interact poorly with the physics system due to no substeps.
Checklist
I have done my best to ensure that…
- [x] …I have familiarized myself with the CONTRIBUTING.md file
- [x] …this change follows the coding style and design patterns of the codebase
- [x] …I own the intellectual property rights to this code
- [x] …the intent of this change is clearly explained
- [x] …existing uses of the Panda3D API are not broken
- [x] …the changed code is adequately covered by the test suite, where possible.