hi everybody here, hope you can help me. i work on a classical point and click adventure game, with a inventory bar on the bottom of the screen. in the inventory there are small widgets displaying the ojbects the player has taken. problem: i constantly check the mouse position for two reasons: - my cameras are slighly panning inverse to the mouse movement so my viewport is slightly moving while moving the mouse - if the mouse position is at the bottom of the screen the inventory moves up into the screen and the scene gets blurred, if the mouse position gets up again the inventory moves down again, not to be seen and the scene gets unblurred again. also i have the different inventory objects.i can drag them around with holding the left mousebutton
everytime i start draggin an object, the mouse position isnt updating anymore. after releasing the object again, the mouse position is updating again
- so first there is a visible step movement in the camera, while normally the movement is smooth
- while dragging an object onto the scene the inventory bar should move down again and the scene should get unblurred. both is not working cause the mouse position isnt updated anymore …
i hope i made the problem understandable for you all and really hope someone has a solution for this. kind regards stucki
During drag operation the mouse position is not sent to the controller. You can get the mouse position from the Pointer Event, I think it’s called GetScreenSpacePosition.
Thx for the answer. Could you explain this a little more detailed please, as i am a noob in blueprinting. Whats the pointer event exactly ? And where do i have to place it ?
so i guess i made it working more or less.
i found about using the pointer event and i can read Screen Space Position now.
two problems i have with this now:
- the drag position seems only to update when i move the mouse over another inventory object button
- it only updates once the mouse moves over another inventory object button
- so if i print the screen Space Position to my screen i have no continous changing coordinates, only once ever when the dragging gets over another button
hope its somehow understandable
thx again for guiding me that far.
would be great if i could it make work perfekt …
I was just writing about what you discovered and yeah, you’re right. You will get screen coordinates for as long as you’re dragging over another widget.
What I generally do when working with widgets, I do not add them to the viewport. Instead, I create a master widget with just a canvas and add any widgets as children of that canvas. This master widget then acts as widget controller, like a hub for all widget related stuff, keeps track of references, handles Z order and so on.
Another thing that a master widget can do is to provide you with ScreenSpacePosition since you’ll be dragging over it.
Having it in onDragOver will get you continuous coordinates.
thx again for your detailed explanation. i think i do understand i will try it tomorrow…
wouldnt it be so much easier when mouse position just keeps updating when mouse is dragging.
I cant see any reason why it should stop updating at all, cause it should give me the mouse position dragging or not
Could this be a bug ? Is it possible to get in contact with an unreal engine developer to talk about this ??
Sorry but i ma new to all this scripting stuff.
As far as I know this is not a bug. The mouse is captured by the drag operation, it stops sending data to the viewport which, it turn, is no longer able to forward mouse info to the player (controller).
It’s one of the quirks of blueprint UMG.
You can request a new feature here:
sorry to bother you again, but i am not getting any further myself
the most bootom object in my inventory_hud is the canvas object.
how can i apply the onDragover to it or do i have to apply it to the invetory objects ?
i cant find a ondragover function at all ???
please could you explain this again a little more detailed to me ?
thx very much in advance
It’s in the override menu:
And try it like so:
If you skip AbsoluteToLocal, you’ll get true screen coordinates - so if you play in a window, the numbers might be off.
wow it works ! you sir are a genius !!!
i wouldnt ever have found the “on drag over” overide function myself !
thx very very much
if i may be so unpolite and ask one further question (else it may again take me days to find or find not the solution for )
now that i have the mouse coordinates while dragging (Yeeeeehaaa !! ) , how can i find out which object in my scene is under exactly these coordinates while dragging and if dragging has ended
You would need to deproject mouse coordinates back into 3d space and trace from the camera to a hit location:
I’m saving the resulting vector in *LastHitPos *variable. You can use in in the *onDrop *override and spawn an actor at those coordinates.
Hi Everynode, i cant say how grateful i am. Your effort in helping me is really amazing ! thx again very much !! Now i am coming close to having my point and click mechanik work !!!
one small glitch right now (i guess there will be more along the way, there always are ) is that once i stop moving the mouse while dragging the mouse, coordinates seems not to be updated anymore.
if i start moving the mouse again (still dragging) its starting again to update the coordinates.
i guess thats the true meaning of dragging … its only called dragging when its moving ??
but as my camera is positioned via these coordinates, everytime i stop moving the drag my camera position gets back to default values
and as i retain dragging around it gets back to real position, so everytime i stop moving and start again ther is a camera hickhack, if you know what i mean.
is there a solution for this also or is there a better way than using “ondragover” ?
thx again, i am learning a lot with your help.
please tell me if i am getting on your nerves !!
Not sure how you’re keeping the camera updated or what the set up is like.
I can only assume that you have a Tick event that updates the camera position or/and you use Inputs which also fire all the time and try to keep the camera at a specific location. The whole process is then interrupted when you start dragging and manually override current camera movement. I’ve just tested onDragOver and it fires every frame even if the mouse is still.
What you could try doing is to have one centralised location where you tell the camera what to do. Let’s say in the PlayerController:
And then ensure that the only thing you ever update is the DesiredCameraLocation. The tick in the controller will handle the smooth transition.
If you want to use draggable widgets to control the camera this is quite unlikely.
i found the problem, it was a problem that the mouse position was also checked, when the mouse drag was checked. so both checkings wrote to my x and y variables and got mixed up.
setting a new bool “is_dragging” and doing the mouse position check only when “is_dragging” is false does the trick.
No camera hickups anymore … tadaaaaa !!
you were right, i am positioning the camera on every tick. All my “global” variables are stored in my pc_game_instance. so i can cast to them from everywhere in the game.
Would be so much easier to have kind of global variables i am used to from programming some years ago. i really hate to to all these “cast to everything” …
inventory logic is handled in my inventory_hud widget. Maybe you are right i should add the logic to my pc controller, too …
cant say it enough: THX very much