0
Not a bug

Character controller Diagonal movement issues

Niukeh 7 months ago in Game Creator updated 7 months ago 5

Hi Martí :

When you set up a top down camera the diagonals on the character controller doesn´t behave as expected .

The closer the camera is to be 90 degrees in the X axis the less diagonal movement the character does.

If the camera is rotated 45 degrees in the X axis the diagonals are perfect. It also affects gamepad aiming.

For the last couple of months Im working in a top down game and i was just dealing with it rotating the camera only 70 degrees in the X axis as a temporal solution.

As a suggestion maybe you can add an option to emulate topdown prespective movement and aiming in the character controller. Or a separate camera that handles the raw movement . Dont´know the best way of dealing with it :)

Thank you !

 

 Some screenshots showing the issue:

clean setup,  Camera character and plane. It behaves the same regardless of using camera motors or not. 

Camera Rotated 89 X axis  . Input :Doing diagonals with keyboard or controller

 

Camera rotated 45 X axis  input :same as above, diagonals works as expected

Camera Rotated 90 X axis  Input: pressing diagonals and  up down, the caharacter only moves roght and left.

Unity version:
2018.4.15f
Game Creator version:
1.1.5

Answer

Answer
Not a bug

This issue is due to the camera being perpendicular to the target/Player. It's a math problem actually. The solution is to slightly tilt the camera so it's not 90º respect to the floor.

If you're interested, what we do to know what direction should the player move to when pressing the directional input, is to transform the key stroke's space into camera space, so the player moves according to the camera's direction.

For example, the W key is mapped to the Forward vector of the camera's direction. However, if the camera is looking 90º down to the player, the camera's forward vector is a direction going downwards; This means that this vector will have a magnitude of 0 when scaled to fir the normalized XZ plane.

Not sure if this is clear or I made it even more confusing. In simpler words: make the camera have at least 1 degree from the player's top-down direction.

Yes. 

In Z Offset you cant give less than 2 or movement stop working right. And if you close between 2 and 5 the two key movements (w+d or s+a buttons) stop react. The angle of movement is less accurate the lover Z offset is set.

So this camera motor do not work with too high top-down view. It is needed to find a custom one. 

Right, Bear in mind it happens with any camera regardless of having or not having camera motor, so it happens also with another camera controllers.

Answer
Not a bug

This issue is due to the camera being perpendicular to the target/Player. It's a math problem actually. The solution is to slightly tilt the camera so it's not 90º respect to the floor.

If you're interested, what we do to know what direction should the player move to when pressing the directional input, is to transform the key stroke's space into camera space, so the player moves according to the camera's direction.

For example, the W key is mapped to the Forward vector of the camera's direction. However, if the camera is looking 90º down to the player, the camera's forward vector is a direction going downwards; This means that this vector will have a magnitude of 0 when scaled to fir the normalized XZ plane.

Not sure if this is clear or I made it even more confusing. In simpler words: make the camera have at least 1 degree from the player's top-down direction.

Sorry Marti, but diagonals doesn´t work even if the camera is slightly rotated. As you can see in the first example the camera is 89 degrees and it doesn´t works . the only rotation that makes the diagonals move the characer actually in precise diagonals is to rotate it 45 degrees so  there is a issue . Please take some minutes to run a test . Thank you!

+1

I tested again, sorry i was mistaken,The only way to make precise diagonals is to have the camera at 0 rotation in the X axis not 45 degrees.