I’m trying to have a static mesh follow the mouse cursor, like right on top of it.
I have it working… sort of. However the mesh is moving in the opposite direction of whereever the cursor goes and it’s nowhere near the cursor either.
Any idea what’s wrong here?
Sorry, forgot to mention that my game is played from a top down perspective. I don’t need (or want) any z depth. I just want a mesh to follow the cursor in the X and Y axis.
Just tried this too and it’s fairly hilarious what it does; maybe try with a raycast instead? There are several videos about that.
The problem is the mouse position is in “screen space” which has very little relation to your world space. There should ideally be some screen to world conversion node. I’ll to see if I can find it in a bit.
Get mouse position is providing the position of your mouse on the screen in 2D space. If you want something to happen in your level (in 3D space) you will naturally get weird results (I just fairly recently learned this the hard way just like you :D).
Anyway the solution is to “get hit location under cursor”
You will get a usual hit result which you can break to get the hit location which is what you want to use.
This also enables you to ignore actors like other pawns or dynamic level objects or to check for everything just as you please.
I hope this helps.
Gosh I never would have figured that out. Thanks a lot
One problem though, as I mouse over other objects in the scene the mesh moves on top of them. I can understand WHY it’s doing that, but I’m not sure how to stop it from doing it. Ideally I just want the mesh to right through other objects.
You can do a “get hit result under cursor by objects”. For the objects array pull out the line and select “make array”. There you can select the collision types)(world static, world dynamic, pawn, etc). Make sure only your ground is world static and all your objects have “block dynamic” selected or just set the collision type manually to world dynamic.
Awesome! Thanks so much for all the help
Hi, I’d like to know how to move the objects with the mouse in 3d space. Right now the object behaves strangely and jumps right to my face when I click on it
As I wrote in my answer the solution is to use “Get Hit Location Under Cursor” which will provide the location of the point when you shoot a trace from your camera, through your mouse onto the map since “Get Mouse Position” is returning just it’s location in screen space (The coordinates on your screen which the mouse is currently located. That’s not data about your game or map).