Make Character Face Direction of Movement with Stationary View Type Camera

Jroo

New member
Hi,

So I've been trying to make a top-down game that features sections where you move a character. I was hoping I could use the Opsive character controller for this even though I know its more meant for 1st-person/3rd-person view where the camera is attached to the player. I want the camera to static, positioned above everything.

I have accomplished this by creating a new View Type class for the camera, following the code example here: https://opsive.com/support/documentation/ultimate-character-controller/camera/view-types/ This worked pretty well


Pressing W sends the player upwards, S downwards, D right, A left (and using the left joystick on the controller sends the character in the same direction as the joystick). This is exactly what I wanted in terms of controls! The one problem is the player does not rotate based on where they are going, so they are always facing north. This means going south is slower since the character is backpedaling, so obviously undesirable for a top-down game.

I tried editing the public override Vector3 LookDirection() function to return a vector in the same direction as movement, however I'm pretty sure that only changed the character's head rotation.


Not sure where to start with this, so if anyone could point me in the right direction that would be helpful. I imagine somewhere I'll need to update the character's rotation based on the input vector or their velocity but I don't know where would be the most elegant part of the code to do that.

Thanks!
 
What MovementType are you using, I would think TopDown would do this (there is a variable called something like look in move direction)?

EDIT: at the very least you will see how the TopDown MovementType sets the change in yaw.
 
Last edited:
Top