Last weekend, I tried to map a stick to movement for an off-center object and it was more complicated than expected: I had a point in the world and I wanted world-space vectors corresponding to screen-space directions while compensating for the camera’s projection. (So that if I were to draw a ray along them it would form a perfect screen-space “+”, even off-center). I got it working with a game jam level of efficiency, but now I’m wondering… what is the right way to do this?

Hmmm. I was expecting to get taken to school on camera projections on that — it seems like something anyone implementing a 3rd person controller would hit. Although, I guess the dozen or so examples I've seen all fail at this, so maybe off-center 3rd person characters is an edge case?


@nulldiver Have only thought about this for one minute...but I would expect the camera's world-space "right" and "up" axes to just work, even for an off-center object, assuming a standard perspective projection?

@reedbeta yeah, of course. In my initial haste, I neglected the critical bit of translating "up" into camera "forward", which is no longer aligned to with "up" due to the projection... so up means running into the screen along an apparent vertical line (as it would for an object at screen center)

Sign in to participate in the conversation
Gamedev Mastodon

Mastodon server focused on game development and related topics.