bevy_xpbd icon indicating copy to clipboard operation
bevy_xpbd copied to clipboard

inverted sign wastes hours of girls life

Open Cassumbra opened this issue 11 months ago • 3 comments

image the -= there WHY wasted hours of my life after copying this code and trying to figure out why my first person character controller was all fucked up this is my fault for writing code and just not really being fully mentally present, probably, but i just want to know why. why. did you somehow place the camera in a weird position and the movement didnt look right so you inverted the sign? why. please fix this. i dont know what you would have to do to fix this. if you put the camera on the opposite side i'm pretty sure it would fuck up the horizontal movement instead of the vertical movement??? so idk what you have to do to fix this or WHY its like this but please please please fix this

Cassumbra avatar Feb 28 '24 02:02 Cassumbra

Unfortunately, this isn't really something I can fix. The sign is negative there because of Bevy's right-handed Y-up coordinate system. In Bevy, +Z is "pointing towards the screen", while "forward" is -Z, which you can see from Transform::forward:

pub fn forward(&self) -> Direction3d {
    -self.local_z()
}

There's a lot of reasons why Bevy uses this coordinate system, and it's also consistent with e.g. Godot and a lot of other tools. Cart (the lead dev of Bevy) has some reasons listed here: bevyengine/bevy#10488

Here's also Freya's chart on coordinate systems: (copied from the discussion)

281936146-3f2d1284-95f8-4f90-a8c9-64c83be5bcb8

(Unreal sitting alone in the corner lol)

Jondolf avatar Feb 28 '24 12:02 Jondolf

yeah, i cant really think of any sort of thing that would fix it, maybe the best thing to do would be to simply add a comment next to the code to point out the inverted sign?

Cassumbra avatar Feb 28 '24 20:02 Cassumbra

Inverse left and right buttons... The inversion has to happen, but it should happen in player local coordinate system, not world coordinate system

MiniaczQ avatar Feb 28 '24 21:02 MiniaczQ