Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Child Entities Lag Behind Parents #231

Closed
jcornaz opened this issue Mar 16, 2022 · 4 comments · Fixed by #241
Closed

Child Entities Lag Behind Parents #231

jcornaz opened this issue Mar 16, 2022 · 4 comments · Fixed by #241
Assignees
Labels
bug Something isn't working

Comments

@jcornaz
Copy link
Owner

jcornaz commented Mar 16, 2022

As reported in the discussion #230:

Using Heron 2.2.0 with 2d feature in bevy 0.6.1:

When creating child entities (with sensors attached, and a visualization component like a circle from the lyon crate), the children lag behind the parent when using velocities to move the parent rigidbody which is of type RigidBody::KinematicVelocityBased.

When creating the same structure directly with rapier2d, the same lagging behind can't be observed, so I assume it has to do with heron directly.

Is that a known issue, or is there something special that needs to be considered when using child entities with rigidbodies?

@jcornaz jcornaz added the bug Something isn't working label Mar 16, 2022
@jcornaz jcornaz self-assigned this Mar 16, 2022
@jcornaz jcornaz modified the milestone: ,mkkkkkkkk Mar 16, 2022
@jakoschiko
Copy link

I observed a similar lag when I tried to sync a camera to a body.

My guess: heron's step systems are responsible for updating bevy's Transform (see here). They are running in CoreStage::PostUpdate (see here). bevy's GlobalTransform are being updated in the same stage. Its doc says:

This system runs in stage CoreStage::PostUpdate. If you update theTransform of an entity in this stage or after, you will notice a 1 frame lag before the GlobalTransform is updated.

@jakoschiko
Copy link

I was able to fix my problem with

.add_system_to_stage(
    CoreStage::PostUpdate,
    set_camera_to_player
        // The player's `Transform` is updated here
        .after(PhysicsSystem::TransformUpdate)
        // The camera's `Transform` is used here
        .before(TransformSystem::TransformPropagate),
)

@jcornaz
Copy link
Owner Author

jcornaz commented Apr 12, 2022

Yes, this is the problem (and solution).

I just didn't have time to solve it yet as I was on holiday. Hopefully (but unsure), I may have time this weekend.

If you want to fix it yourself and open a pull request, you can. Just don't forget to add a test ;-)

@jcornaz jcornaz changed the title Child Entities Lag Behind Parents Child Entities Lag Behind Parents when using RigidBody::KinematicVelocityBased Apr 15, 2022
@jcornaz
Copy link
Owner Author

jcornaz commented Apr 15, 2022

Actually, after a deeper look, I cannot manage to create a test that reproduces the problem.

@Occuros, could you share how to reproduce?

EDIT: I managed to reproduce, and fix it. I should be able to publish the fix today

@jcornaz jcornaz added the need-reproducer Not yet clear how to reproduce the problem label Apr 15, 2022
@jcornaz jcornaz removed their assignment Apr 15, 2022
@jcornaz jcornaz removed the need-reproducer Not yet clear how to reproduce the problem label Apr 15, 2022
@jcornaz jcornaz self-assigned this Apr 15, 2022
@jcornaz jcornaz changed the title Child Entities Lag Behind Parents when using RigidBody::KinematicVelocityBased Child Entities Lag Behind Parents Apr 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants