# Drawing target under mouse on a plane

**URL:** <https://forums.unrealengine.com/t/drawing-target-under-mouse-on-a-plane/605567>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [July 15, 2022, 1:01pm UTC](https://forums.unrealengine.com/t/drawing-target-under-mouse-on-a-plane/605567 "2022-07-15T13:01:24Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ilkatheon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ilkatheon](https://forums.unrealengine.com/u/Ilkatheon)\
**Post date:** [July 15, 2022, 1:01pm UTC](https://forums.unrealengine.com/t/drawing-target-under-mouse-on-a-plane/605567/1 "2022-07-15T13:01:24Z")

</div>

Hi,

I’m having some issues trying to create a “strategic map” for my game. Think of the map as a zoomed out view of a space ship and that this view will allow players to move their mouse to positions in 3d and then issue orders for that position.

If you have played Homeworld, it’s a similar idea.

My thinking is that the steps would be

- select mode (like “Move”),
- move the mouse on a horizontal plane, click,
- then select on a vertical plane (all within a large sphere).

That final position in x,y,z space is where we want to move to.

I think I’ve sorted out the first and second steps - I can place a cursor under my mouse on the horizontal plane using collision plane intersection (PlaneXY), but I’m a bit stumped how to then lock X and Y and allow the player to move the cursor through Z (the vertical step)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/9/2/8922b1239b240fc31db538a86cf8bb056f92f6b4.png)

TIA

---

<div class="post-metadata">

**Author:** ![pezzott1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pezzott1/32/1215068_2.png) [@pezzott1](https://forums.unrealengine.com/u/pezzott1)\
**Post date:** [July 15, 2022, 4:56pm UTC](https://forums.unrealengine.com/t/drawing-target-under-mouse-on-a-plane/605567/2 "2022-07-15T16:56:43Z")

</div>

> [@Ilkatheon](#):
>
> My thinking is that the steps would be
> 
> - select mode (like “Move”),
> - move the mouse on a horizontal plane, click,
> - then select on a vertical plane (all within a large sphere).

Something like this?  
 ![WithinaSphere](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/5/2/3523396edf8fcb6a320286b3264d5dbc92768c04.gif)

* * *

I’ll share BP later. Had to go afk half way adding comments to the nodes. 😅

---

<div class="post-metadata">

**Author:** ![pezzott1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pezzott1/32/1215068_2.png) [@pezzott1](https://forums.unrealengine.com/u/pezzott1)\
**Post date:** [July 15, 2022, 11:59pm UTC](https://forums.unrealengine.com/t/drawing-target-under-mouse-on-a-plane/605567/3 "2022-07-15T23:59:01Z")

</div>

idk if this is overly complicated… but here it is:

1. We need to have Left Click cycle to the three stages we want: off (0), find horizontal (1) and find vertical (2). We use an int we increment per click with its value repeating using modulus:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/c/f/acfdd76bc1487725f5d14eec7434ce677313018e.png)
2. the rest is managed in a tik event in my case:

- We have a branch that is only true when we have made the first click and we set the variables we will be using in various math expressions:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/e/a/2eab53b4a1e444e7c64624d12d021c76ccee92d6.png)
- We get the planes, firs the horizontal then the vertical:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/a/2/aa2d7c7e0b1fb0a4d9eef7c19fdd630dfeb128d5.png)
- Next we get the intersection point based on planes:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/1/9/e192c5da1d672cc23711c76feb8ba943c0106d27.png)
- We have a branch to get horizontal on 1 and vertical on 2:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/e/7/1e7e0ac44d19e1802f15daa6d9d1d9443f9eb772.png)
- For the horizontal, we trace to get the intersection vector:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/5/8/a589e5dec5f42defb15a3f9e321ce7bbf21f9fc8.png)
- the vertical point is a bit more complicated…  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/0/4/c0466075087f3f31efe5785d1fe35dda3337af30.png)
- And that is it. Here are the debug nodes:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/e/e/5ee559b00cb229fb5d493b29afc8348a3f1d286f.png)

This is the entire blueprint:  
[![Imgur](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/f/0/ef0feacc91a7f02d7f247f77abfaa5e0e9b7fcb7.png "imgur.com") ](https://imgur.com/inRIZss)

---

<div class="post-metadata">

**Author:** ![Ilkatheon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ilkatheon](https://forums.unrealengine.com/u/Ilkatheon)\
**Post date:** [July 16, 2022, 12:07am UTC](https://forums.unrealengine.com/t/drawing-target-under-mouse-on-a-plane/605567/4 "2022-07-16T00:07:02Z")

</div>

Wow - thank you so much for the effort here

I’ll need some time to digest this!

---

<div class="post-metadata">

**Author:** ![Ilkatheon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ilkatheon](https://forums.unrealengine.com/u/Ilkatheon)\
**Post date:** [July 16, 2022, 4:28am UTC](https://forums.unrealengine.com/t/drawing-target-under-mouse-on-a-plane/605567/5 "2022-07-16T04:28:42Z")

</div>

Works like a charm! Had to figure a few small things (camera / pawn / etc), but that was pretty easy once I started to see what it was all about.

![ezgif.com-gif-maker](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/7/1/37122657ee9938c82983e3cf58515d941726e90b.gif)

---

<div class="post-metadata">

**Author:** ![Moleman2009](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Moleman2009](https://forums.unrealengine.com/u/Moleman2009)\
**Post date:** [October 14, 2022, 7:03am UTC](https://forums.unrealengine.com/t/drawing-target-under-mouse-on-a-plane/605567/6 "2022-10-14T07:03:30Z")

</div>

Hello, I am currently working with this blueprint, I believe I have it working correctly however I am having an issue with the Secondary plane disjointing from the rest, is there something I possibly missed? It seems to rotate fine but is oriented off center when the camera is rotated. The flat horizontal plane holds place just fine. I temporarily disabled my camera panning while the mode is active to see if it helps and it is less exaggerated if you cannot move the camera while performing this activity.

Here is an example of the issue mentioned [Imgur](https://i.imgur.com/3jfSmAK.gifv)

---

<div class="post-metadata">

**Author:** ![November\_3\_Zero](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@November\_3\_Zero](https://forums.unrealengine.com/u/November_3_Zero)\
**Post date:** [November 2, 2023, 2:58am UTC](https://forums.unrealengine.com/t/drawing-target-under-mouse-on-a-plane/605567/7 "2023-11-02T02:58:29Z")

</div>

Hi folks, I’m a bit late to this thread, having just found it. I would like to know how set up the incremental integer and math expression for the mouse clicks, as I’m not familiar with those BP methods.  
If anyone is still around to explain, I’m all ears! 🙂

I’m hoping to use this method to create a Homeworld style movement system for my game.

Cheers!

---

<div class="post-metadata">

**Author:** ![November\_3\_Zero](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@November\_3\_Zero](https://forums.unrealengine.com/u/November_3_Zero)\
**Post date:** [November 2, 2023, 9:08pm UTC](https://forums.unrealengine.com/t/drawing-target-under-mouse-on-a-plane/605567/8 "2023-11-02T21:08:16Z")

</div>

I was able fix that issue, however I’m having trouble with getting the BP to work. Do I just assign it to a random pawn to test?

---

<div class="post-metadata">

**Author:** ![November\_3\_Zero](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@November\_3\_Zero](https://forums.unrealengine.com/u/November_3_Zero)\
**Post date:** [November 3, 2023, 8:52pm UTC](https://forums.unrealengine.com/t/drawing-target-under-mouse-on-a-plane/605567/9 "2023-11-03T20:52:14Z")

</div>

@Moleman2009 Did you ever get this to work?

---

<div class="post-metadata">

**Author:** ![pezzott1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pezzott1/32/1215068_2.png) [@pezzott1](https://forums.unrealengine.com/u/pezzott1)\
**Post date:** [November 3, 2023, 9:10pm UTC](https://forums.unrealengine.com/t/drawing-target-under-mouse-on-a-plane/605567/10 "2023-11-03T21:10:27Z")

</div>

Hey. I see you made this [post](https://forums.unrealengine.com/t/homeworld-style-rts-control/1353390). Still need help?

---

<div class="post-metadata">

**Author:** ![November\_3\_Zero](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@November\_3\_Zero](https://forums.unrealengine.com/u/November_3_Zero)\
**Post date:** [November 5, 2023, 9:37pm UTC](https://forums.unrealengine.com/t/drawing-target-under-mouse-on-a-plane/605567/11 "2023-11-05T21:37:02Z")

</div>

Hi @pezzott1 Yeah, I’ve been trying all sorts of things to get this to work and I keep hitting a wall. I feel like it shouldn’t be this hard haha.  
Did you ever manage to get this working?

---

<div class="post-metadata">

**Author:** ![pezzott1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pezzott1/32/1215068_2.png) [@pezzott1](https://forums.unrealengine.com/u/pezzott1)\
**Post date:** [November 6, 2023, 4:03pm UTC](https://forums.unrealengine.com/t/drawing-target-under-mouse-on-a-plane/605567/12 "2023-11-06T16:03:34Z")

</div>

> [@November\_3\_Zero](#):
>
> I’ve been trying all sorts of things to get this to work and I keep hitting a wall

Share what you’ve tried and what is the issue.

---

<div class="post-metadata">

**Author:** ![November\_3\_Zero](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@November\_3\_Zero](https://forums.unrealengine.com/u/November_3_Zero)\
**Post date:** [November 8, 2023, 9:36pm UTC](https://forums.unrealengine.com/t/drawing-target-under-mouse-on-a-plane/605567/13 "2023-11-08T21:36:46Z")

</div>

I tried to implement the above BP but it did nothing at all. I also tried [this](https://forums.unrealengine.com/t/homeworld-style-rts-control/1353390) but this didn’t work at all.
