x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Getting/Setting Mouse position not working correctly

I boiled down an issue I was having where I was trying to limit the mouse position to inside the aspect ratio of my camera. I was testing this with PIE in the selected viewport. Two things were happening:

  1. When you Shift-F1 for the mouse cursor, the mouse will move continuously to the left. The mouse is fine otherwise when stationary (I have an object following mouse position so I know that it was fine).

  2. If the mouse is not stationary (Not using Shift-F1, just the object following the mouse in game) weird things happen. It seems to be some sort of mouse acceleration issue. If I move my mouse very slowly to the right, the mouse will actually start to veer left. If I move it faster the effect is less obvious. I should mention I have mouse acceleration disabled in Windows.

Simply using this c++ in a Tick will replicate the issue:

 FVector2D MousePosition;
 APlayerController* Controller = UGameplayStatics::GetPlayerController(GetWorld(), 0);
 ULocalPlayer* LocPlayer = Cast<ULocalPlayer>(Controller->Player);
 Controller->GetMousePosition(MousePosition.X, MousePosition.Y);
 LocPlayer->ViewportClient->Viewport->SetMouse(FMath::RoundToInt(MousePosition.X), FMath::RoundToInt(MousePosition.Y));

I put the RoundToInt for good measure in case of floating point accuracy but it didn't make a difference either way.

Product Version: UE 4.10
Tags:
more ▼

asked Apr 02 '16 at 05:33 PM in Bug Reports

avatar image

Rael5
122 13 19 30

avatar image Doug E ♦♦ STAFF Apr 04 '16 at 08:02 PM

Hey Rael5-

Because you are calling this code on tick, it is continually trying to calculate and set the mouse position. When you move the mouse to the right (increase the X), the next tick it will again round the value and if the movement wasn't enough to round up, it will round down and move the mouse back to the left as you're seeing.

If I have misunderstood what you are referring to, can you supply a sample project with the issue you're seeing so that I can investigate the issue directly?

Cheers

Doug Wilson

avatar image Rael5 Apr 05 '16 at 04:58 PM

The 'mouse moving to the left' happens without moving my mouse at all.

I can make a sample, but is there a specific way I should upload it, and should I upload the whole project folder?

avatar image Doug E ♦♦ STAFF Apr 05 '16 at 05:18 PM

If you're able to create a sample project you can delete the Saved and Intermediate folders and then zip the entire project folder and attach it here. Another solution would be to zip the project and upload it to google drive or Dropbox, then post the download link here or as a private message to me on the forums.

avatar image Rael5 Apr 06 '16 at 10:37 PM

Here we are, it's a code project, I deleted some of the larger generated VS files otherwise the zip would be 300 MB, hopefully that's fine. When you use PIE and press shift-F1, the 'mouse moving left' thing happens.

mousebug.zip (5.0 MB)
avatar image Doug E ♦♦ STAFF Apr 11 '16 at 02:00 PM

Hey Rael5-

When I opened the project and used Shift+F1, I did not see the mouse drifting left. I did notice that when the mouse touches any of the four borders it instantly returns to the top left corner of the game window. Can you let me know if you have any extra controllers or other peripherals that may be providing input to the mouse?

avatar image Rael5 Apr 14 '16 at 06:42 PM

Hmm, I don't have any controllers setup.

Here's a video of what's happening just to clarify. It shows the mouse moving left, as well as what you described with the mouse going to the top left corner when they touch the borders.

video.rar (2.4 MB)
avatar image Doug E ♦♦ STAFF Apr 14 '16 at 07:55 PM

In addition to the mouse drifting left I noticed the mouse jumping around in the video which is also not happening in the project you sent. I also tried adding the code you provided originally to a new project as well but did not see the mouse behaving as shown in your video.

avatar image Rael5 Apr 18 '16 at 01:24 PM

Yea I'm not sure what's causing it, I tried changing my mouse settings to default in windows (6/11 mouse speed and mouse acceleration on, I usually have it at 3/11 and mouse acceleration off) but it still happens. Sorry that I couldn't replicate the conditions. It's not a blocker for me right now or anything but if it is in the future I could do further testing on other machines to see if it happens anywhere else or if it's just some one-off on my machine.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hey Rael5-

I'm sorry we were not able to track down the cause of the strange mouse behavior for you though I am glad it is not blocking you from development. If this does continue to be a problem, let me know if you're able to test/reproduce this on another machine and we can continue to investigate.

Best of luck in your projects,

Doug Wilson

more ▼

answered Apr 19 '16 at 07:44 PM

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question