Skip to content

Expose PhysicsServer's (and Physics2DServer's) space_step #1373

@ETdoFresh

Description

@ETdoFresh

Describe the project you are working on:
I am currently working on a lower level client side prediction / server reconciliation clone of asteroids. I saw the demo project on youtube (https://www.youtube.com/watch?v=B02bil7G2S4) of Client side prediction and Server reconciliation in Godot 4.0. I asked the question how this was being done. @AndreaCatania responded back immediately and told me he was using kinematic bodies and space_step. He asked if space_step is not currently exposed, to put in an issue. (This is my first one, so apologies if I'm doing this wrong!)

Describe the problem or limitation you are having in your project:
Currently, I have no way to re-simulate physics via gdscript. I can run physics in realtime, but if I need to do server reconciliation, I do not have access to any step() function.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Exposing a step() function will allow network programmers to re-simulate the world and make corrections as necessary.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

# Very psuedo! :p
func resimulate_step(delta):
    PhysicsServer.space_step(space_rid, delta)

func correct_and_resimulate(corrected_transforms, number_of_steps_to_resimulate):
    correct_all_physics_body_transforms(corrected_transforms)
    for i in range(number_of_steps_to_simulate):
        resimulate_step(fixed_rate)
    apply_correction_to_all_nodes()

If this enhancement will not be used often, can it be worked around with a few lines of script?:
I think resimulating physics seems like something that would take many man hours to reproduce if not exposed.

Is there a reason why this should be core and not an add-on in the asset library?:
I think everyone that has to do some kind of live networking game will need this in their coding toolkit.

PS - I'm currently working in 3.2. It's be great if this can be exposed here. But if not, I'll definitely make the switch to whichever version has it! :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions