Top Down Camera Forward Axis and Right Stick

Vlaxep

Active member
Hi,

I need to be able to rotate my TopDown camera to different angles (like 'The Ascent' twin stick shooter).

Using controller/gamepad the movement direction is fine and adjusts for different camera rotation, however the Player 'Look/Aim' using controller RIGHT STICK does not. It remains fixed as if for Forward Axis of 0,0,0,

How can I adjust or combat this to allow for any forward axis rotation, including dynamic adjustment?
 
Also I'm using Rewired FYI. So my Right stick input is set to 'Mouse X' and 'Mouse Y' accordingly.

On the whole the input works great, just doesn't adjust for the Camera Forward Axis which is all I need.
 
For this situation you should subclass the TopDown ViewType and add the ability to modify the forward axis.
 
For this situation you should subclass the TopDown ViewType and add the ability to modify the forward axis.
Sorry Justin I think I didn't word my question correctly.

I AM able to modify the Forward axis without problem, the issue is that the 'Aiming/Looking' of the character then doesn't match in relation to the Camera.

ie.
With Forward axis 0,0,0 , Right Stick to UP yields Player looking Up/Away from camera as expected
With Forward axis 1,0,0 , Right stick to UP yields Player looking towards the Right, rather than the 'new' Forward.

(Mouse cursor aiming works perfect - no issues, as it is based on cursor position)

Perhaps there is some other setting I need to adjust dynamically when I need to rotate the forward axis?

So as the forward axis rotates when player moves to a new area of the map, I will need to change forward axis to suit the environment, and at all times Right Stick UP needs to be UP and not the 'old' UP etc.
 
Last edited:
Can you tell me how to reproduce it within the demo scene? So you have look in move direction enabled?
 
Hi @Justin sure,

So using the Rewired demo scene at:
Assets/Opsive/Shared/Integrations/Rewired/Demo.unity

- Add 'TopDown' movement type to Nolan in UCLocomotion component
- Add 'TopDown' view type in Main Camera 'CameraController' component
- In RewiredInputManager, in 'Joystick Maps' need to 'invert' the following axes in gamepad template:
RightStick X (Mouse X)
RightStick Y (Mouse Y)
- I am NOT using 'Look in Move Direction', I want to use Right stick to aim independently of move direction

Playing the scene now with Forward Axis 0,0,0 yields movement and look direction correct in relation to camera angle.

Now changing Forward axis to eg. 1,0,0 yields adjusted movement direction but look direction with right stick is NOT CORRECT, it remains relative to the original camera Forward Axis. So in this example Right stick UP makes the player look to the RIGHT, RIGHT looks DOWN etc.

So somehow the 'movement' adjusts dynamically relative to the adjusted camera angle, but the RightStick looking/aiming does not.
 
Last edited:
Hi @Justin.

Unfortunately that doesn't solve this issue. I think that may be for a different scenario?

I need 'Relative Camera Movement' to be true
and 'Look in Move direction' to be false

So great example is in this video of 'The Ascent', (at this timecode) the player walks to a new section and the Camera axis/angle adjusts suiting the new area - I want to do the same. When playing it feels seamless and the RightStick aiming dynamically adjusts to suit also
 
Hm, you tried adding that line into TopDown.cs from the other forum thread right? Can I check what version of UCC you're on? The top-down area in the demo does seem to work for me (with that fix).
 
Hm, you tried adding that line into TopDown.cs from the other forum thread right? Can I check what version of UCC you're on? The top-down area in the demo does seem to work for me (with that fix).
Andrew is that with rewired? I'm using rewired.

I added the line of code too!
 
@Andrew pretty sure I'm updated to 2.3.5 - I have climbing pack so it's one of the latest versions.

So below is a link to a video of my setup, I'll explain.

Video begins and shows my Locomotion movement settings: Relative Camera Movement true, and Look in move direction false

Then Camera forward axis 0,0,0.
For demonstration I ONLY use RightStick UP and DOWN to aim.

0:22 - Movement and RightStick aim UP and Down (all correct and as expected)

0:40 - I change the forward axis to 5,0,0 (as an example, but I will need to be able to change to any angle)
Now I am still demonstrating RightStick UP and DOWN, but you see the character looks left and right in relation to Camera.

Same thing happens in the Opsive Rewired Demo when changing the forward axis.

 
What if you deselect Relative Look Direction on the movement type? If you add two joystick mobile controls are you able to reproduce the issue? I don't think Rewired is a factor in this case. I've attached my testcase scene and if you can modify it to reproduce the issue then that would be great.
 

Attachments

  • TopDown.unitypackage
    12.8 KB · Views: 4
What if you deselect Relative Look Direction on the movement type? If you add two joystick mobile controls are you able to reproduce the issue? I don't think Rewired is a factor in this case. I've attached my testcase scene and if you can modify it to reproduce the issue then that would be great.

Hi Justin I can't get any controls whatsoever to work in that scene.

Standard input doesn't work
Rewired input (with Rewired Input Manager+RewiredEventSystem, Std EventSys disabled, RewiredInput added to Nolan)
Mobile on screen controls don't work, only thing that happens is character's head moves to follow the mouse, that's it.

I also tested in Standard FullOpsive Feature Demo, adding all rewired components: in the top down area, changing forward axis yields same issue, RightStick aiming is offset by the amount that Camera 'Forward Axis' is rotated away from 0,0,0.


Deselecting 'Relative Camera Movement' causes the same issue. (Is that the setting you meant by 'Relative Look Direction'? - The one under 'MovementType' in UltimateCharacterLocomotion? - Otherwise if it's Relative Look Direction' I don't know where to find it maybe?)

Really scratching my head on this, I also tried reassigning the RightStick inputs in RewiredInputManager to be 'Right Joystick X/Right Joystick Y'
but made no difference.

Is this just something that it's not set up to do? Is there some other way to achieve this camera angle rotation I'm after? I really just need to be able to change angle by up to 90 degrees both directions, but obviously it needs to maintain the same direction aiming as I've been trying to achieve....
 
Last edited:
Like for eg. say if the Camera rotates 90 degrees to the left, can I adjust the Character's input reference by the same factor to adjust for this somehow?

Or the RightStick input itself?
 
Hi @Justin @Andrew

I'm not great with C# but sifting through the TopDown.cs (movement type) I'm seeing this section regarding 'Look towards' and doing the calculations based on whether cursor is visible or not.

At line 99 it sets var direction = Vector3.zero;

Hovering my cursor over 'zero' of Vector3.zero; it tells me that this means it's shorthand for a Vector 3 of 0,0,0

So if my thinking is right , that's why the reference for the look direction is ALWAYS 0,0,0, regardless of which direction the camera is facing!

So is there a way to allow this to be calculated based on the current 'ForwardAxis' instead?

So it dynamically updates including while the ForwardAxis is 'rotating'? (eg. I plan on changing ForwardAxis slowly, or at once but with a slow 'rotation speed' of around 0.2-0.5 so it's a nice transition for a new area of the environment)
 
Ok so I think perhaps I've come across a better solution suggestion on Opsive discord.

Rather than trying to rotate with forward axis and dynamically adjust input/aim/look, it was suggested to consider rotating the world around the player. So now I've stumbled across using

Transform.RotateAround

So performing this function on the entire scene parented to a single encompassing object, I can specify the player as the 'point' to rotate around, and 0,1,0 for y-axis only, then I can control the amount and check for the desired rotation in the calculation.

My concern will be how this affects NavMesh and AI pathfinding, as well as how the rotation will affect AI movement (fingers crossed the AI transform 'sticks to' it's NavMesh location)

Interested to hear what you guys think, whether this is probably the optimal solution?

Below is a video of the rough result, I think it works rather well.

Perhaps you also might have a suggestion to avoid the effect of the players' character maintaining its rotation relative to camera which is very obvious only when standing still while rotation occurs. It's not too bad but very noticeable at 0:15

 
That does seem like a viable solution - although to be honest I'd be pretty worried about the potential knock-on effects of rotating the entire world.

I'd still be interested to find the cause of the original issue with top-down movement. It definitely works in the demo when using a mouse input, so I wonder if it's something to do with how Rewired captures gamepad input, although to be honest that seems unlikely. If you were able to DM me a small repro project I could take a closer look.
 
That does seem like a viable solution - although to be honest I'd be pretty worried about the potential knock-on effects of rotating the entire world.

I'd still be interested to find the cause of the original issue with top-down movement. It definitely works in the demo when using a mouse input, so I wonder if it's something to do with how Rewired captures gamepad input, although to be honest that seems unlikely. If you were able to DM me a small repro project I could take a closer look.
Hi Andrew, I haven't had any problems with mouse input, nor controller left stick. Only right stick aim when forward axis is rotated to other angles apart from 000

Mouse input works exactly as expected no matter what forward axis is set to, I assume because it's cursor based. Looking at the code I think it's because in that line 99 or thereabouts doesn't take into account what direction the camera is looking I think. Seems to set 'direction.X' and 'direction.y' only based on right stick input, without regard too anything else.
 
Hm, yes I think I see what you mean now. I don't have a gamepad to test with right now, but I wonder if you could just modify direction based on the camera's current angle? E.g. if the camera is rotating about the Y axis, then you should be able to just add the camera's rotation to direction, something like direction += m_Camera.transform.eulerAngles.
 
Top