There are two approaches. You can build up from KinematicBody
or customize the RigidBody
.
Using the KinematicBody
you can write the movement however you want. Just write it in _physics_process
. You can handle the collisions by using move_and_collide
which returns a KinematicCollision
object where you get the info of the collisions, allowing you to write your own collision resolution.
Using RigidBody
, I suggest to set custom_integrator
to true and override _integrate_forces
which is called during the physics process with a PhysicsDirectBodyState
allowing you to read and write the state of the physics object.
Regardless of the approach, for the modification you want, you will have to keep track of the acceleration yourself, and set the velocities. The RigidBody
can keep track of forces for you, or you can do it on your own. You will be writing your physics integration step regardless.
Know that the different physics nodes (including joins/constraints) are all using the PhysicsServer
api behind the scenes. Which you could call directly if you so desire (this could be to optimize your code, or to do something the nodes do not provide out of the box).
It is, in theory, possible to provide your own physics engine for Godot (as it currently ships with two for you to pick from). I haven't seen documentation on how to do that. I only know for sure that you will be building from source (which isn't that hard).
I also want to mention that Godot physics is getting a rewrite for Godot 4.0 (it probably won't ship with two anymore). And a new API to provide the back end for the PhysicsServer
is expected for Godot 4.1 (so plugging your own physics engine won't be a dark art anymore, we can expect third party physics engines to be a thing at some point).
Addendum: There is another approach, actually. Use Godex, and write your physics using its Entity-Component-System architecture.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…