Stopping camera rotation and starting again without 'retained' movement?

DankP3

Active member
So i want to stop camera rotation whilst interacting with the menus (both running off the mouse). I was sure years ago this could be done by switching the look mode to manual. This approach kind of works with the state system, but if the mouse is moving when the states change that movement is retained and the camera keeps spinning in the same direction.
As an alternative i have used the Gameplayinput event to stop the camera rotation (probably just disabling UnityInput and others). This works fine (stops the camera rotation immediately). However, when you reenable the inputs the camera moves briefly in the direction the mouse was moving in before the event was triggered, which manifests as a visual jerk - presumably some smoothing movements are retained and then used?

The desired result is that the camera stops moving whilst going to do UI things and when camera is returned it should not be moving unless it is receiving current input.

Any pointers would be helpful, thanks.
 
I believe I've noticed this happen with smoothed input as well. A workaround fix for now should be to add these 3 lines into PlayerInput.EnableGameplayInput:

C#:
m_SmoothLookBuffer = new Vector2[m_SmoothLookSteps];
m_SmoothLookBufferCount = 0;
m_SmoothLookBufferIndex = 0;

But I'll pass this on to Justin to hopefully add it in to an update soon.
 
Thanks, but i think this is not quite right.
Without that code, the camera jumps in the direction it was travelling.
With that code, it seems flick in the direction of travel and back, like a twitch. It is not behaving as if it has 'zeroed out and cleared itself'
 
I would go with the approach of calling OnEnableGameplayInput. I am having trouble reproducing the issue after making Andrews change. In the demo scene the menu is enabled with the escape button and when I resume the camera doesn't continue to move. Does it work correctly for you in that scene?
 
So I do see in the demo scene. In this clip i escape game play 4 times. I then reset gameplay by presing right mouse (aim). The aim causes a slight camera movement (I'd expect from the animation), but you will notice that the swinging movement that precedes the first and last escapes carries over when gameplay is enabled:


EDIT: i realise i misread your message. this is the effect without Andrew's code, but i see with.
 
Last edited:
I'm having trouble reproducing it with Andrew's change. If you output the returned value of PlayerInput.GetLookVector do you see a non-zero value after you have resumed the game?
 
OK, so i understand my issues in my scene and I'll work through them in some way, but I still see a difference in the demo scene, depending on what i do (Andrew's code included). If I escape whilst moving fast and then to return to the game escape again followed by the resume button, all works well. If I escape whilst moving fast and then restart with another action, such as right mouse then the movement carries through. Perhaps the EnableGameplayInput is not called in this setting or something is different. But this is a demo issue and not relevant to the fact the code works if implemented correctly and I had other issues that I will now deal with.
Marking solved and assuming this will go in future releases? thanks
 
Thanks for the follow up. Andrews code will be included in future release. I still think that it's strange that I'm not able to reproduce it even when performing another action to resume.
 
Top