#Smooth translation?

20 messages Β· Page 1 of 1 (latest)

plucky nymph
#

Please consider the attached video. When I rotate the camera the gun follows along nicely but if you pay attention you will notice that the movement is a bit jaggy. The gun basically twitches/jumps a bit sideways.
Any suggestions on what could be the reason and how to fix this?

obsidian linden
#

This looks like a one frame lag, for example you're using the GlobalTransform of the camera to update the gun's Transform, but either you do it before the gun's GlobalTransform is updated from its Transform (in TransformPropagateSet I think, in PostUpdate) or you do it after but then it's the gun's GlobalTransform that is not reupdated until the next frame.

If that's what's happening, the easiest way to solve this would be to make the gun a child of the camera.
If you don't want to do that, I think it's possible to re-apply the tranform propagation system, or if you're sure that the gun has no parent you can simply calculate the GlobalTransform and update it yourself

plucky nymph
#

Thanks, will investiage the suggested options πŸ™‚

obsidian linden
#

(just in case: a child's Transform is relative to its parent's GlobalTransform, and that is handled by Bevy you don't have to do anything)

#

If you know for sure your camera doesn't have a parent you can also use its Transform directly to calculate the gun's position

plucky nymph
#

πŸ‘

plucky nymph
#

do you recall any code snippet that I could look up when it comes to "I think it's possible to re-apply the transform propagation system" ? πŸ™‚ if not no worries πŸ™‚

obsidian linden
#

@plucky nymph I don't, I've never tried to do this and not 100% sure it's possible
I believe you could just re-add the systems in TransformPropagateSet at a strategic place

plucky nymph
#

@marble oracle since i'm using bevy_fps_controller here would you have any suggestion as to how you would solve the above with your plugin? πŸ™‚

#

(building on top of the minimal example really)

obsidian linden
#

If you're using rapier it has its own transform propagate systems to replace bevy's I think

plucky nymph
#

i tried but run into visibility problems but i also didn't spend too much time on it yet so before doing deep dive checking if there are low hanging fruits πŸ™‚

#

will check πŸ™‚

obsidian linden
#

Ah yeah to make something a child of a camera and still have it visible you need to add a VisibilityBundle to the camera

#

Because visibility is propagated through the hierarchy too

marble oracle
marble oracle
#

I tried to do this for a game that was using my own crate and ran into the same problem

marble oracle