# How can I lock a component to follow the mouse on the Z-axis? 

**URL:** <https://forums.unrealengine.com/t/how-can-i-lock-a-component-to-follow-the-mouse-on-the-z-axis/2357571>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [February 25, 2025, 3:36pm UTC](https://forums.unrealengine.com/t/how-can-i-lock-a-component-to-follow-the-mouse-on-the-z-axis/2357571 "2025-02-25T15:36:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pwallace2004](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@pwallace2004](https://forums.unrealengine.com/u/pwallace2004)\
**Post date:** [February 25, 2025, 3:36pm UTC](https://forums.unrealengine.com/t/how-can-i-lock-a-component-to-follow-the-mouse-on-the-z-axis/2357571/1 "2025-02-25T15:36:28Z")

</div>

Hi all, I’m currently making a 2.5D sidescroller where a flashlight is involved in one of the levels. At the minute, I have a flashlight following the mouse in a 3D space when I want it to follow my mouse on the Z-Axis so the player can move the flashlight up and down rather than along the floor.

 ![image_2025-02-25_151947882](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/1/8/b189efb6180578c891d37a25c60df7a6a505390a.png)  
At the minute, this is what I have set up. Thanks in advance for everyone’s 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:** [February 25, 2025, 5:32pm UTC](https://forums.unrealengine.com/t/how-can-i-lock-a-component-to-follow-the-mouse-on-the-z-axis/2357571/2 "2025-02-25T17:32:24Z")

</div>

Have a look here, there’s a bunch of examples:

> [@Left Mouse button pressed and released equivalent in enhanced input (or drag and drop)](https://forums.unrealengine.com/t/left-mouse-button-pressed-and-released-equivalent-in-enhanced-input-or-drag-and-drop/1633884/18):
>
> Here’s some script allowing for picking up stuff and moving it in a specific plane only we determine ourselves manually: The green debug plane visualises what’s going on. In short: shoot a beam (trace) from the screen centre towards the projected mouse cursor, when it eventually intersects that plane (which is infinitely large), place the actor at the intersect world coordinate. If I change the normal: You could derive this Normal from the actor itself instead:
