# Movement according to location of mouse on screen

**URL:** <https://forums.unrealengine.com/t/movement-according-to-location-of-mouse-on-screen/409403>\
**Category:** Blueprint\
**Tags:** unreal-engine, UE4, Blueprint, question\
**Created:** [November 12, 2017, 12:10pm UTC](https://forums.unrealengine.com/t/movement-according-to-location-of-mouse-on-screen/409403 "2017-11-12T12:10:50Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_f6e959cc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f6e959cc](https://forums.unrealengine.com/u/anonymous_user_f6e959cc)\
**Post date:** [November 12, 2017, 12:10pm UTC](https://forums.unrealengine.com/t/movement-according-to-location-of-mouse-on-screen/409403/1 "2017-11-12T12:10:50Z")

</div>

Hello,

I’m trying to make a spaceship (also the player) to move continuously according to the location of the mouse on screen using blueprints.&nbsp;  
For example, when the crosshair in on the top middle of the screen the spaceship will&nbsp;continuously pitch upwards, same goes to the yaw.  
They did the same in Everspace ([EVERSPACE™ on Steam](http://store.steampowered.com/app/396750/EVERSPACE/))

Thanks for any help

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [November 12, 2017, 1:48pm UTC](https://forums.unrealengine.com/t/movement-according-to-location-of-mouse-on-screen/409403/2 "2017-11-12T13:48:09Z")

</div>

If you just want up/down, then something crude like this will do:

 ![219907-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/d/1/bd1536a5bdae48ef4d61ea8aee7d588b0201d14e.png)

If you need something more advanced, you’d want a directional vector from the centre of the screen to mouse position. Not only would this give all directions but also the distance from the centre which can be then interpreted as speed - the further you’re from the screen centre with the cursor, the faster you go.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f6e959cc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f6e959cc](https://forums.unrealengine.com/u/anonymous_user_f6e959cc)\
**Post date:** [November 12, 2017, 1:56pm UTC](https://forums.unrealengine.com/t/movement-according-to-location-of-mouse-on-screen/409403/3 "2017-11-12T13:56:52Z")

</div>

Thank you soo much,

can you show me or explain a little bit more about the second method ?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [November 12, 2017, 2:33pm UTC](https://forums.unrealengine.com/t/movement-according-to-location-of-mouse-on-screen/409403/4 "2017-11-12T14:33:44Z")

</div>

Here’s what I mean, you can get a direction and distance relative to the centre of the screen like so:

 ![219910-capture.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/c/7/fc74ce8099043160b644a833f5d5e83769c91034.jpeg)

I put it in the HUD class, it makes it easier to draw 2d debug on screen:

[![https://gyazo.com/33dd705a9b7bae25900ccbea062675eb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/a/c/aac38f7a07955670ec9cf0dc5ab30eb1c2b1c43a.gif)](https://gyazo.com/33dd705a9b7bae25900ccbea062675eb)

Print those values and observe them change - this should give you an idea regarding how to apply them to yaw/pitch. The number here shows the distance, you can use is as speed when calculating rotation interpolation.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f6e959cc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f6e959cc](https://forums.unrealengine.com/u/anonymous_user_f6e959cc)\
**Post date:** [November 12, 2017, 9:10pm UTC](https://forums.unrealengine.com/t/movement-according-to-location-of-mouse-on-screen/409403/5 "2017-11-12T21:10:54Z")

</div>

I’m really new to all of this and you have been so much help, though i still don’t really know how to translate this to the spaceship movement

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [November 13, 2017, 10:24am UTC](https://forums.unrealengine.com/t/movement-according-to-location-of-mouse-on-screen/409403/6 "2017-11-13T10:24:07Z")

</div>

The most basic setup would look like this:

 ![219982-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/d/c/fdcf0dfc3c49b48ab5619a00be530e1712cdbef7.png)

[![https://gyazo.com/8eee5ed2c3eefd444f78c60541373db4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/c/3/ac34f7fde04a2e51822f668bd67601456a73a141.gif)](https://gyazo.com/8eee5ed2c3eefd444f78c60541373db4)

However, what you really need is a solid 6DoF, handling gimbal locks.

In order to get this working properly, you’d need to set up proper movement first. And only then worry about adding mouse screen input speed.

If you’re new to all this, may I suggest you start with a [6Dof][2] tutorial:

[https://forums.unrealengine.com/community/community-content-tools-and-tutorials/1217-tutorial-6-dof-flying-pawn-like-descent](https://forums.unrealengine.com/community/community-content-tools-and-tutorials/1217-tutorial-6-dof-flying-pawn-like-descent)

Link to the tutorial is in the very first post. Once you have it working, what I said above should make more sense.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f6e959cc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f6e959cc](https://forums.unrealengine.com/u/anonymous_user_f6e959cc)\
**Post date:** [November 13, 2017, 10:29am UTC](https://forums.unrealengine.com/t/movement-according-to-location-of-mouse-on-screen/409403/7 "2017-11-13T10:29:45Z")

</div>

Thank you so much for all the help.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f6e959cc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f6e959cc](https://forums.unrealengine.com/u/anonymous_user_f6e959cc)\
**Post date:** [November 13, 2017, 11:08am UTC](https://forums.unrealengine.com/t/movement-according-to-location-of-mouse-on-screen/409403/8 "2017-11-13T11:08:24Z")

</div>

I know it may sound a bit exaggerated but can you send me this spaceship project to understand exactly how you did that ?

if you prefer not to its totally understandable

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [November 13, 2017, 12:30pm UTC](https://forums.unrealengine.com/t/movement-according-to-location-of-mouse-on-screen/409403/9 "2017-11-13T12:30:51Z")

</div>

It’s a project where I mess around with random things, it’s such a mess that I do not know what’s what.  
I duplicated the 2 blueprints that are used and cleaned them up a bit:  
[https://drive.google.com/drive/folders/10lVhop8jESs-h9oOx92ThEfXF8NiQ6K1](https://drive.google.com/drive/folders/10lVhop8jESs-h9oOx92ThEfXF8NiQ6K1)

The Pawn seems to be default with a mesh, camera and springarm, you just need to assign it your own static mesh. The controller is pretty much default as well. It handles all logic seen above.

If you want to use custom pawn and controller, you’ll need a custom GameMode: [https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/SettingUpAGameMode/Blueprints/index.html](https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/SettingUpAGameMode/Blueprints/index.html)

You can’t do much without them anyway.

---

<div class="post-metadata">

**Author:** ![Darkentik](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Darkentik](https://forums.unrealengine.com/u/Darkentik)\
**Post date:** [June 23, 2018, 12:39pm UTC](https://forums.unrealengine.com/t/movement-according-to-location-of-mouse-on-screen/409403/10 "2018-06-23T12:39:52Z")

</div>

Hey Everynone,  
could you reup the project? I have still problems getting this working for a spaceship.

Regards,  
Darkentik

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [July 9, 2018, 10:17am UTC](https://forums.unrealengine.com/t/movement-according-to-location-of-mouse-on-screen/409403/11 "2018-07-09T10:17:15Z")

</div>

@Darkentik, just saw this. I no longer have it. Sorry.
