Forum rules - please read before posting.

Drag camera rotation acting wildly for some players

edited April 2021 in Technical Q&A

Unity v 2019.1.3f1
AC v1.72.4

Hi!
I have an isometric camera that is set to rotate by clicking the middle mouse button and dragging. This works slowly and smoothly on my end, both in editor and builds. But many players have reported a highly sensitive camera that often snaps back to its original position.

I doubt that this is due to mouse sensitivity - they can't be using a mouse that much more sensitive than me, surely? Also, it works correctly on my end, so I doubt it has anything to do with my camera/ player etc settings.

Here is a video showing the issue:

I checked "Scale speed with input magnitude" as an attempted fix - not confirmed if it works yet. The issue was reported with that unchecked:

imagesasassa" alt="" title="" />

imageScreenshot-107" alt="" title="" />

«1

Comments

  • Note that checking "Scale speed with input magnitude" apparently fixed the issue for mouse users, but it makes the camera rotation using the right stick with the controller extremely slow. Any ideas how to speed that up specifically?

  • Is the cursor locked at this time?

    I wonder if it's related to screen resolution - do you have details of what resolutions players who reported the issue were using?

    the camera rotation using the right stick with the controller extremely slow. Any ideas how to speed that up specifically?

    Is this also using drag-control? You may want to alter the camera's settings if you have a means of detecting the player's input. The camera's fields can all be changed through script.

    One other thing to consider is the Advanced Third Person Camera over on the Downloads page. The intent is for this camera to eventually replace the current Third Person GameCamera.

  • edited April 2021

    Is this also using drag-control? You may want to alter the camera's settings if you have a means of detecting the player's input. The camera's fields can all be changed through script.

    Yeah both are using the same camera/ system, but detecting input and changing the values based on that would lead to a lot of complex issues/ bugs.

    One other thing to consider is the Advanced Third Person Camera over on the Downloads page. The intent is for this camera to eventually replace the current Third Person GameCamera.

    If I replace the current camera with the advanced one (by deleting the current component and adding this instead) this will detach the camera from all actions in action lists, correct?

    At this stage with a full, released game, I'm not sure how much of a game breaking change I should be making regarding this. If there was a way to only speed up the right stick control somehow, that would have been perfect.

    I've asked players their resolution as well, let's see what they say. Edit: They played at the same resolution as me - 1920x1080

  • detecting input and changing the values based on that would lead to a lot of complex issues/ bugs.

    Only mentioned because of this thread.

    If I replace the current camera with the advanced one (by deleting the current component and adding this instead) this will detach the camera from all actions in action lists, correct?

    Most likely, yes.

    If there was a way to only speed up the right stick control somehow, that would have been perfect.

    How are you using the right stick to control the camera? By mapping it to "middlemouse"? In the regular or new Input system? If you're reading from the same input, and all your settings are the same, then it's either a case of tweaking with that input's values, or introducing a means of detecting the input method.

    Again, is the cursor locked at the time?

    If the resolution is constant, could the issue be framerate related? Though it should be framerate-independent, do you get differing behaviour if you enforce a fixed framerate?

  • Only mentioned because of this thread.

    I've been only using it in specific moments (QTEs) but for the camera use, I'd have to have it turned on all the time, which would cause a lot of issues.

    How are you using the right stick to control the camera? By mapping it to "middlemouse"? In the regular or new Input system? If you're reading from the same input, and all your settings are the same, then it's either a case of tweaking with that input's values, or introducing a means of detecting the input method.

    Yes, mapped to middlemouse, in the regular input system.

    Again, is the cursor locked at the time?

    I've locked the cursor by Player: Constrain, but the system cursor does move around outside the game. (I've checked lock system cursor when locking AC cursor)

    I'm not sure what to do about this at the moment, so I'm going to try and figure out if this is a widespread issue or if it's only a few users, and will proceed accordingly.

  • Note that checking "Scale speed with input magnitude" apparently fixed the issue for mouse users, but it makes the camera rotation using the right stick with the controller extremely slow. Any ideas how to speed that up specifically?

    Say I stick with this. For mouse with this setting, putting the camera spin speed at 4 works well for the mouse, and is super slow for the controller. Putting this at 21 for the controller stick makes it quick for the controller, but super fast for the mouse.

    Could there be a way to tie this value to a slider in the options menu, call it "camera rotation sensitivity" or something, and then transfer that value in each scene to the required cameras?

    I feel that would be the best non-destructive solution.

  • edited April 2021

    Though it'd be best to know the underlying cause of difference in mouse behaviour between users, a sensitivity option would be an approachable workaround.

    This'd involve multiplying the camera's spinSpeed value based on a Global Float Variable that represents the sensitivity, i.e:

    float sensitivity = GlobalVariables.GetVariable ("CameraRotationSensitivity").FloatValue;
    float defaultSpeed = 4f;
    GetComponent <GameCameraThirdPerson>().spinSpeed = defaultSpeed * sensitivity;
    

    However, it may also be possible to rely on Input overrides to multiply the controller's input by some amount. It's not the "middlemouse" input exactly, though - this is just a button to activate drag mode. Which input is mapped to the right-stick's 2D motion that's allowing for movement once middlemouse input is pressed? CursorHorizontal/CursorVertical?

  • Thanks for the code! I'll give that a shot :)

    Which input is mapped to the right-stick's 2D motion that's allowing for movement once middlemouse input is pressed? CursorHorizontal/CursorVertical?

    This might be a little complicated by the fact that I'm using Rewired as well. There, I've simply set - right stick to middlemouse as seen in this picture:

    imageassad" alt="" title="" />

  • This'd involve multiplying the camera's spinSpeed value based on a Global Float Variable that represents the sensitivity, i.e:

    float sensitivity = GlobalVariables.GetVariable ("CameraRotationSensitivity").FloatValue;
    float defaultSpeed = 4f;
    GetComponent ().spinSpeed = defaultSpeed * sensitivity;

    Sorry I'm a bit confused - where do I use this script? Is it a custom Action or a component to attach to the camera?

  • This might be a little complicated by the fact that I'm using Rewired as well.

    That's the detail I'm trying to get at when asking about your input system.

    It's not the "middlemouse" input that affects the input speed, but "CursorHorizontal".

    Are you able to apply a modifier to this specific input within Rewired?

    If not, you may be able to modify the integration script to apply one manually.

    For example, replacing:

    private float CustomGetAxis(string AxisName)
    {
        return player.GetAxis(AxisName); 
    }
    

    with:

    public float speedFactor = 3f;
    private float CustomGetAxis(string AxisName)
    {
        if (AxisName == "CursorHorizontal")
        {
            float controllerInput = player.GetAxis("CursorHorizontal_Controller");
            if (Mathf.Approximately (controllerInput, 0f))
            {
                return controllerInput * speedFactor;
            }
        }
        return player.GetAxis(AxisName); 
    }
    

    This technique would involve renaming the controller's mapping to CursorHorizontal to CursorHorizontal_Controller, so that it can be detected independently from the mouse.

    Sorry I'm a bit confused - where do I use this script? Is it a custom Action or a component to attach to the camera?

    Placed on a component attached to the camera - though unoptimised, it'd work in an Update function.

    Try the axis renaming method first though. If it works, you should be able to avoid having a custom option.

  • edited April 2021

    Thanks! Will this affect the horizontal movement of the cursor across the board? I want to keep the right stick movement for the controller the same for all other uses (first person camera movement, cursor movement etc) and only modify the spin speed for the third person camera.

    Edit: Also, oddly enough modifying the integration script with the suggested changes makes spinning stop working completely, even for the mouse.

  • My mistake - a typo in the code.

    It should also be possible to limit the speed increase only when the middlemouse input is held:

    public float speedFactor = 3f;
    private float CustomGetAxis(string AxisName)
    {
        if (AxisName == "CursorHorizontal" && player.GetButton("middlemouse"))
        {
            float controllerInput = player.GetAxis("CursorHorizontal_Controller");
            if (!Mathf.Approximately (controllerInput, 0f))
            {
                return controllerInput * speedFactor;
            }
        }
        return player.GetAxis(AxisName); 
    }
    
  • edited April 2021

    Thanks! This seems to speed up the camera rotation for the controller, but there are a few problems/ questions-

    1. The mouse camera rotation is not working properly. When clicking and dragging the middle mouse button, nothing happens, but as soon as I release the button, there is a slight movement as if due to the momentum of the movement it didn't respond to earlier. (It's like I can somewhat flick the camera with the mouse, instead of consistent movement throughout by holding down the mm button and moving the mouse)

    2. Does this definitely only affect the camera rotation? The on-screen mouse cursor (which is also controlled by the right stick/ CursorHorizontal) seems to move a little sluggishly/ with lag/ momentum. As if it's slipping on grease - only with the controller. The first-person movement looks fine, but I'm finding it hard to tell.

    3. I see there are 2 places where I can enter a float value in the code. Entering 1000f in the second one doesn't seem to speed up the rotation with the controller/ right stick either. Does changing those values do anything?

  • Do you have a controller plugged in at the time, and is CursorHorizontal_Controller only mapped to the right-stick?

    It should be that the script change only affects the value of CursorHorizontal while middlemouse input is held - try placing Debug.Log statements above the first return statement to see what the input is and when it's overriding regular behaviour.

    I see there are 2 places where I can enter a float value in the code

    The above code? The speedFactor is the only thing that should need changing to affect the intensity. If this is set to 1, then there should be no effect - is this the case?

    It may be worth adding a sensitivity option after all.

  • edited April 2021

    Weird. I just reapplied the code, and set the speedFactor to 1, and it actually works exactly the way I want it to. The mouse issue and the greasy cursor movement mentioned above are fixed, and the camera spin/ rotation speed for both mouse and controller are perfect, as desired.

    Not sure what changed from before, but I'll consider this fixed for now unless I run into issues again! Thanks for taking the time and for the quick fix idea, saved me a lot of rework with the sensitivity option! :wink:

  • So I've just returned to this in order to make some updates to the game.
    In my last message above I'd said that setting the value to 1 somehow made both the controller and mouse camera rotation speeds work well. (which didn't really make sense but it worked at the time)

    Returning to this now, I noticed that the original issue remains - the controller rotation speed is much slower. Setting the speedFactor to a high value (12) fixes this - as the code was intended to do.

    The issue now is, this does affect the cursor speed even outside of camera rotation. So, there are moments when you control the cursor with the right stick (like when using an in-game computer) here, vertical cursor movement with the right stick works correctly, but the horizontal movement is sped up. Setting speedFactor to 1 fixes this, but slows down the rotation speed.

    It would seem the && player.GetButton("middlemouse")) part isn't doing anything. Any way to ensure that it only affects camera rotation, and nothing else?

  • The syntax for player.GetButton("middlemouse") should be correct - if it's not being read, it may be an issue on the Rewired side of things.

    Though, an alternative means of detecting if the camera is being dragged can be gotten with:

    && KickStarter.playerInput.GetDragState () == DragState._Camera
    
  • Interesting - this completely disables horizontal movement when using the right stick as a cursor.

    Camera rotation works correctly though.

    For clarity, here's the full code -

    using UnityEngine;
    using System.Collections;
    using Rewired;
    using AC;
    
    public class ACInputRewired : MonoBehaviour
    
    {
    
        public int playerId = 0;
    
        private Rewired.Player player;
    
    
    
        void Start()
    
        {
    
            AC.KickStarter.playerInput.InputGetButtonDownDelegate = CustomGetButtonDown;
    
            AC.KickStarter.playerInput.InputGetButtonUpDelegate = CustomGetButtonUp;
    
            AC.KickStarter.playerInput.InputGetButtonDelegate = CustomGetButton;
    
            AC.KickStarter.playerInput.InputGetAxisDelegate = CustomGetAxis;
    
            player = Rewired.ReInput.players.GetPlayer(playerId);
    
        }
    
    
    
        private bool CustomGetButtonDown(string buttonName)
    
        {
    
            return player.GetButtonDown(buttonName);
    
        }
    
    
    
        public float speedFactor = 1f;
        private float CustomGetAxis(string AxisName)
        {
            if (AxisName == "CursorHorizontal" && AC.KickStarter.playerInput.GetDragState() == DragState._Camera)
            {
                float controllerInput = player.GetAxis("CursorHorizontal_Controller");
                if (!Mathf.Approximately(controllerInput, 0f))
                {
                    return controllerInput * speedFactor;
                }
            }
            return player.GetAxis(AxisName);
        }
    
    
    
        private bool CustomGetButton(string buttonName)
    
        {
    
            return player.GetButton(buttonName);
    
        }
    
    
    
        private bool CustomGetButtonUp(string buttonName)
    
        {
    
            return player.GetButtonUp(buttonName);
    
        }
    
    }
    

    And the rewired settings -

    imageimage" alt="" title="" />

    Input settings -

    imageimage" alt="" title="" />

  • Try this:

    public float speedFactor = 1f;
    private float CustomGetAxis(string AxisName)
    {
        if (AxisName == "CursorHorizontal")
        {
            float controllerInput = player.GetAxis("CursorHorizontal_Controller");
            if (!Mathf.Approximately(controllerInput, 0f) && AC.KickStarter.playerInput.GetDragState() == DragState._Camera)
            {
                return controllerInput * speedFactor;
            }
            return controllerInput;
        }
        return player.GetAxis(AxisName);
    }
    
  • edited December 2021

    Hmm this fixes the controller issue, but now the mouse camera rotation doesn't work at all.

    Edit: I wouldn't mind some way to change the Speed Factor value in the component during runtime through a Object: Send Message or Call Event or something. I tried this but wasn't able to make it happen. I could then switch the value between 12 and 1 depending on what was happening in the game through an Action List.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.