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"

Printing Out Mouse Position

Hello All! I'm trying to at the moment implement a 2D sidescroller shooter esk minigame I have the mouse shown already, and i know that i can draw a line trace from the character to the mouse. However i have been trying to just print out the value of the mouse via the screen to then take those values and plug into an aim offset later in the future. At the moment i have tried![alt text][1]

Just wondering how may i do this with some C++?

When i get the mouse position and the aim offset to work i plan to just shoot a raycast straight out of the gun. Since at that point it should be pointing in the correct position it should hit [1]: /storage/temp/81748-mouse.png

Product Version: UE 4.10
mouse.png (15.9 kB)
more ▼

asked Mar 11 '16 at 05:24 AM in C++ Programming

avatar image

7 4 4 7

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

2 answers: sort voted first

You need to pass the X and Y as references (if you're not sure what that means, read about it here) so the function can set them, like so:

 float X;
 float Y;
 MyController->GetMousePosition(X, Y);
 // Now your X and Y have their corresponding values

Edit: I just noticed they have an example in the documentation: https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/APlayerController/GetMousePosition/index.html

more ▼

answered Mar 11 '16 at 09:46 AM

avatar image

1k 38 13 60

avatar image psychoticpolice Mar 11 '16 at 03:07 PM

I Tried doing something like this yesterday, but something went wrong. However your solution worked so thanks!

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

U can use GetCursorPos(&).For initialisation struct use type - POINT. One trick - if u show off cursor, all will work, because cursor will binding camera vector. (GetCursorPos(&) - standart WinAPI function)

If u need get position from ActorComponent with standart UnrealAPI - use:

 ACharacter* ownerCharacter = Cast<ACharacter>(GetOwner());
 APlayerController* PlayerController = Cast<APlayerController>(ownerCharacter->GetController());
 float X, Y;
 PlayerController->GetMousePosition(X, Y);

If u need it from standart Character class, use this code (we talk about auto-generate Character class):

 APlayerController* PlayerController = Cast<APlayerController>(GetController());
 float X, Y;
 PlayerController->GetMousePosition(X, Y);
more ▼

answered Mar 25 '16 at 11:23 AM

avatar image

24 3 5 10

(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