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"

Object that follows mouse position. How to properly do it with BP?

I try to make simple BP where my actor object will follow mouse position. So I've done it with the simple BP: alt text

but when I run it I get some "inverted" position of my actor. Why is it work like this? I've recorded a video: https://www.youtube.com/watch?v=bvsDagxM3Ns

Product Version: UE 4.8
Tags:
more ▼

asked Jun 21 '15 at 07:50 AM in Blueprint Scripting

avatar image

OrchestralMusician
16 1 4 3

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

4 answers: sort voted first

You are using the mouse location node incorrectly. try something more like this to see how it would work:

alt text

It is unclear what you are truly attempting to do, and as OrchestralMusician stated you may actually want to use the get hit result but i wanted to post a example of the mouse location node you were using.

capture.png (151.1 kB)
more ▼

answered Jun 21 '15 at 11:14 PM

avatar image

RimmyD
2.6k 98 16 97

avatar image OrchestralMusician Jun 22 '15 at 04:43 AM

Thanks it works a little bit better! But it doesn't place actor by the its clicked center. Why does it work like this? I supposed "500" should be calculated dynamically? If I set 850 instead 500 - it works a little bit better but only for some directions. Some directions work better with 500 and some of them better with 800, etc...

avatar image RimmyD Jun 22 '15 at 05:10 AM

by default the location returned will be right in front of the camera, the 500 is a distance away from the camera. The distance is based on what you feel is correct or the needs of the game.

What is the effect you want to happen? Do you want something to appear in front of the camera or on the ground based on the mouse location?

avatar image OrchestralMusician Jun 22 '15 at 06:09 AM

Yes, I want to place Actor (by center of it) on the ground based on the mouse location...

avatar image RimmyD Jun 22 '15 at 03:11 PM

Then you want to go with what Erasio said then. Use the node: "Get Hit Result Under Cursor" This will return a hit result with a location along the ground/objects under the mouse. You can mask what objects get hit to be just your ground plane if you want by adding some custom collision channels.

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

Try using "Get HitResult under Cursor". This outputs a HitResult from which you can take the position on your map and make your actor move there.

Convert Mouse Location doesn't project the location to the world and I generally had a lot of issues with that.

Cheers

more ▼

answered Jun 21 '15 at 01:24 PM

avatar image

Erasio
5.9k 291 86 293

avatar image OrchestralMusician Jun 21 '15 at 02:05 PM

I've already tried it :) It also has strange behavior when I click at the same point two or more times: http://www.youtube.com/watch?v=_soj-Q5zI0Y - why it works like this?

Maybe that function has some bug?

I don't actually understand what does exactly "Get HitResult Under Cursor" return?

avatar image Erasio Jun 21 '15 at 02:37 PM

A trace from your camera through your mouse onto the world. The HItResult outputs as always what was hit, where, with what normal, etc.

Since you use the visibility channel and your actor has visibility it will if you click twice hit the actor and place it there instead. The fix is fairly simple. You use the hit result under cursor for objects and only insert "WorldStatic" into object types. With that it will only look for things which you set to static. By default that's the normal environment but not a pawn etc. This is set in the collision settings of your actors. Just make sure that everything you might move is set to "WorldDynamic" or something besides"WorldStatic".

Like that it will ignore your actor and properly hit where you clicked on the ground.

avatar image OrchestralMusician Jun 21 '15 at 03:01 PM

Sorry but I can't find the setting. Where does it exactly place? I'm new to UE. I've been learning it just for 1 week.

avatar image Erasio Jun 21 '15 at 03:37 PM

It's a different node.

"Get HitResult under Cursor by Objects".

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

To those who may come across this thread in the future. I found a number of issues with Convert Mouse Location to World Space and Get Hit Results Under Cursor by Channel. For most interactions of this nature (where you are trying to place a Building on the Floor for example) - try using Get Hit Results Under Cursor by Object.

Set your Object Trace to what you want to trace for (World Static in most use cases) and it will consistently return the floor location. The biggest issue with the other options that they will trace to the building you are trying to place (thereby defeating the point, you are trying to hit the floor, not what you just spawned) or move the object all over the screen and not the floor where you are trying to place it.

If you're stuck like I was, give Get Hit Results Under Cursor by Object. a try and see if that suits your use case.

more ▼

answered Mar 28 '16 at 01:39 AM

avatar image

Nick Jackson
492 17 14 107

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

I think this is what you are looking for: Folow

All you need to do is change the break vectors to the direction you are facing (X,Y,Z) I don't think +/- matter

Here is a text you you can copy-paste into the BP: Paste

Also, you can subtract your first break vector float you chose by an amount if you want to use less of the viewport to move the mesh (by default it will use the viewport bounds for the movable units, so if the viewport is1920, the mesh will move -960 to 960 units)

folowmouse.jpg (67.9 kB)
pastintobp.txt (17.0 kB)
more ▼

answered Jan 23 '16 at 09:57 PM

avatar image

gmc
93 8 18 19

(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