Song of Horror - An Old-School Inspired, Third Person Survival Horror

Thanks everyone!

@Chillybody: our game does not have classical Resident Evil “tank” controls. They do auto adjust in relation to the camera rotation.

Roughly, what I did was the following. With a keyboard, there are eight possible directions you can move in (from -180º to 180º, in 45º intervals). The first step was dividing these 360º into eight 45º regions, each keyboard direction being the center point of one of them (for example, if “forward” is movement with 0º yaw rotation, then its interval would range from -22.5º to 22.5º).

At begin play, we store the initial control rotation forward and right vectors in a couple of variables. These variables will act as the character’s initial forward movement vector and right movement vector. Now, every frame (every time the input axis functions fire) we check whether the horizontal camera forward vector (the camera forward vector minus the Z coordinate) is in the same interval (the same of my custom eight 45º regions) as the current character forward movement vector (also in horizontal, as our game has no Z movement). If it is not, AND the character’s movement is different from that of the last frame (if any of the axis values have changed, we have this check in order to prevent the vector adjustments from messing up the character movement on camera change when the player is moving steadily. The camera only changes when the character moves differently, for example if he stops), then our character forward movement vector becomes the “adjusted” camera forward vector (with “adjusted” I mean that it becomes the center vector of the region its in. For example, if the horizontal camera forward vector rotation is 38º, the adjusted camera forward vector would have a 45º rotation) and the character right vector becomes the adjusted camera right vector.

For a gamepad it’s mostly the same, although with a few variations in the form of tolerance thresholds, to avoid the vectors changing virtually every frame due to the (potentially) infinite directions a joystick can produce.

I think I explained myself atrociously, but I hope it helps.