Anytime I press a button on my mouse whether its lmb, rmb, mmb, or even my side mouse buttons they all gain temporary control over the camera rotation while the mouse button is held down. My end goal is to make it to where only the rmb does that and the mouse cursor locks to the exact position it was in on the viewport but controls the camera rotation for the time its held and when released goes back to normal. Only asking for help on how i can remove all the other mouse inputs. Ive checked my input settings and all of the enhanced IA but cant find anything that revolves around the button inputs and how to remove them. I usually only use these forums as a last resort so if anyone knows help a fellow out
the input action should define the way the event works.
on the imc you bind which key is assigned to which action (for a specific context (the C in imC)). (input mapping context).
try setting it there.
you will need another action for the other things you want to do.
as for this:
there are a couple of nodes to change the cursor mode
notice that there is another node for actually showing the cursor or not.
note:
if that fixes your query, take a look at the docs, since it’s a well documented core concept, and you might be missing others.
So uh I have very little experience with blueprints and ue 5 itself so what you’re saying isnt clocking to me . I understand IMC is where you put your inputs in but the only input i found for IA_Look was (Mouse XY 2d-Axis) theres nothing in IMC that has to do anything with my mouse inputs.
I think the problem is my input mode. Currently it is set to game and ui only whenever i press shift, bisshiftlocked?=false.
So from my understanding the input mode (game and ui only specifically game) is controlling my game input (lmb, mmb, rmb, side mouse buttons) so what i need to do is set the input mode to ui only but specify it with the widget so it doesnt disable all of my inputs? but what would the widget be and consist of?
sorry if im troubling you with my questions im still learning about game dev in general
ok yeah i think you might be mixing both concepts.
please do check the doc i’ve mentioned it will really help you. at least the basics.
there’s also mat wadstein on youtube which i highly recommend and i’m certain he demoes and explains setinputmode, show mouse, enhanced input, and others. it will greatly help you out i think. https://www.youtube.com/channel/UCOVfF7PfLbRdVEm0hONTrNQ
don’t worry, nothing wrong with asking. if someone can’t or don’t want to reply, they won’t, mostly.
but i do recommend you go through the docs and matt’s channel. it will really help us both.
thanks for sharing your code that really helps. there are several things to comment.
- reorganize your code to not mix the white lines. avoid mixing them like you do. that brings problems. is akin to use the “go to”. and worse because you’re abusing temporary values like at the end of create widget.
- don’t create the widget on the event. create it on begin play. and store the result in a variable (right click > to variable) don’t use a local variable but a regular class variable. then hide and show in the event by adding and removing to viewport. or better yet, set the mode to hidden or collapsed.
- the way you’re using the event doesn’t seem correct to me. instead of using started you should use maybe start and end. and change the input action so that it behaves correctly i don’t remember exactly at the moment, but you can set it so that it starts on button down, and stops on release. i think it’s the default.
- dont use a flipflop. it’s “convenient” but very quickly forces you to make horrible code.
- you can make a function with a bool that : sets the value of “shift held” sets the “use controller rotation yaw” and “show mouse cursor” so you can call it directly instead. and avoid code duplication. maybe setting the input mode too.
other comments
- i would avoid changing the input mode on input. it will make it very confusing. just pick the one that works for you. probably “game and ui”.
- the action for the mouse movement will trigger all the time, regardless of the shift key.
- the shift key is very annoying to detect, because the operative system does not send an event it has to happen with another key. and does not take the mouse into account. it’s a “modifier” key. same for alt and ctrl.
- you could set the shift key as a modifier on the imc or action for the look, i don’t remember. but i would not recommend it.
- i would recommend instead to use rmb or lmb instead of shift. (e.g. dragging the camera or landscape) it’s more intuitive as well. shift is usually for selection.
- the input for the mouse will trigger on movement, all the time. if you want to only move when you press shift, then you need to add a “branch” (aka “if”) that filters by “IsShiftLocked”. again don’t use shift but a mouse button.
- also i recommend avoiding naming the variable after the input or event or environment, instead name it after what it does eg “CanDrag” or “CanMoveCam”, instead of “IsShiftPressed”. it will help you in the future. and also makes more sense but it’ll take me very long to explain why.
- i think i understand what you mean by “taking control of the camera” actually that’s an illusion. what happens is:
- when you click the viewport, and the input mode is set to game only, ue will “capture” the mouse. that means, it hides it, and you cant see it or get it out. and the mouse event is set so that it moves the camera whenever the mouse moves. combined it gives that illusion. which also is the normal way a game works.
- you probably will want to
- on rmb you set a flag “CanMoveCam”, on release you clear it
- on the input action there’s a mode that triggers start on down, and end on release.
- on mouse input you put a branch and only move if the flag is set (please do not mix two events with the white lines (“execution lines”))
- you might get away with an input mode “game and ui”. and on rmb, alongside setting the flag you can also hide and show the mouse (like i said before that’s a different node).
- the downside is that the mouse will be moved on release. but you can also record the mouse position on rmb down, and restore on rmb up
- if that doesn’t work for you. then changing the mode from game to ui on rmb could work as well. when setting the input mode i think you can also tell ue whether to capture or not.
- on rmb you set a flag “CanMoveCam”, on release you clear it
i hope that helps.
(if that helps solve your problems consider marking my post as solution)
Youve been a great help nande, thanks for taking the time to educate and further my learning experince in unreal I really appreciate it. I will follow your advice and im sure this will lead me to the solution im looking for.
Thanks again, you were just the guy I was looking for to set me in the right direction.
Also Its kinda crazy you say this because I was doing this exact thing I was just wondering how i would store the result and had to look back to how my reference works
I’m very happy i was able to help. it makes me happy to share what i know, it helps me learn too and improve. and if it helps you it makes me more happy.
just try things out, and when you find a new roadblock or have a new specific question don’t hesitate to keep asking. that’s how learning is done.
also i just noticed this other thread opened recently, it’s quite similar. it’s funny that he got recommended a similar approach. i was not aware of it. you might benefit from following the thread. (there’s a bell icon to the right below the date scrollbar (but it sometimes get hidden depending on how much you scroll))