More details in the conversation with myself linked below but the skinny is that during PIE on both MAC and I find the C++ reported mouse position is offset by the margin between the editor window and the letterboxed game.
This is quite annoying - I’m reposting to Bug Reports, originally I thought I was just doing something wrong but it seems more buglike now.
I tried reproducing this, and was unable to see the results that you described. Could you provide a screenshot of the results you are seeing, and answer the following questions?
Are you using the binary version of the Editor, or did you build the Engine from source code?
Are you working with C++ or Blueprints when you are trying to retrieve your mouse position?
Could you provide more details about how you are setting this up?
Do you see the same results in a brand new project, or does this only happen in your project?
The result is a box that is often offset from your mouse cursor by the letterbox to window margin.
I might get a to product a test project from a sample later this week if needed but the above should be pretty easy to implement if you have access to C++. It would be pretty surprising if a sample program didn’t have the same issues but stranger things have happened.
The result is a box that is often offset from your mouse cursor by the letterbox to window margin.
I might get a to product a test project from a sample later this week if needed but the above should be pretty easy to implement if you have access to C++. It would be pretty surprising if a sample program didn’t have the same issues but stranger things have happened.
Do both of the functions above go into the player controller? Was there any other code added to run the program?
Additionally would it be possible for you to send us a copy of the blueprint asset that you’re seeing the issue with? If you can uplaod it to dropbox, you can send a private message on the forums with the link to myself or .
Hi , both functions would go into the player controller. I don’t have a blue print exhibiting the problem - I’ve tried putting one together but don’t get valid mouse offset positions in my HUD Blueprint (getting 0’s, tried getting them from the PlayerController actor and the HUD actor).
Moss pointed me towards camera constraints. With them switched off I don’t see the problem. This seems like a workaround though and not a fix for the problem (it will keep me going and I can get rid of my double mouse pointer ugly UI I’ve been using to stay sane!).
I added the code you posted above to my PlayerController derived class and created a blueprint based on that class. After setting the BP in the world setting and attempting to play the game I did not have any box appearing on screen. Is there other code necessary to draw the box on screen? Also, as suggested earlier, could you post a screenshot of what exactly you’re seeing on your machine?
Sorry - I’d assumed when I saw a DrawHUD function in the player controller it would Just Work ™.
My actual draw code is in a hud class that overrides DrawHUD(). I then have a HUD blueprint based on it.
Screen shots are pretty boring, just show a box draw at an offset to the mouse pointer where there offset matches the letterbox size. I’ll see if I can get to it tomorrow!
I apologize for the delayed response. Let us know if you’re still experiencing the mouse offset in the latest version of the engine. We are still investigating this and some additional information would be helpful. Could you post the code class where you setup the box and how you you’re returning the canvas? If possible let us know if you can reproduce this in a new project and what steps you took to do so.
Hi - it’s a little tricky to just post code as I have a lot of extraneous game code that would need to be refactored.
I can confirm that the issue still happens with latest with camera aspect ratio constrained.
In the image attached the mouse pointer was at the left of the view window, and the drawn box is at the left of the green texture which is the left of the constrained game window.
Setting up a pure test bed would take a little bit of time, and currently I’m trying to get a viable release together so I can feed my children so this is lower on my priority list.
Putting the draw code above into an overridden HUD class’ DrawHUD function would work. Rather than using the rCanvas parameter passed in you’d use the HUD classes Canvas pointer (so rCanvas.DrawItem in the DrawSomething function becomes Canvas->DrawItem in AMyClass_HUD::DrawHUD).
Then make sure your Camera actor has “Constrain Aspect Ratio” ticked in it’s default options.
If needed I can give someone access to a github repository with my full project.
When I run this I see that the blue box is exactly under the mouse cursor. The canvas used by the hud is the size of the viewport. The player controller GetMousePosition method will return you mouse coordinates in viewport space (e.g 0,0 is the top left of the viewport). Since they are the same size, the coordinates should be exact. Are you making your own canvas elsewhere? If so you would need to convert the mouse coordinates to the proper canvas space.
If you run the same test I did do you get the same results?