# Character in 3D space following mouseX

**URL:** <https://forum.kirupa.com/t/character-in-3d-space-following-mousex/322630>\
**Category:** flash\
**Created:** [May 27, 2011, 2:26pm UTC](https://forum.kirupa.com/t/character-in-3d-space-following-mousex/322630 "2011-05-27T14:26:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flashead](https://avatars.discourse-cdn.com/v4/letter/f/46a35a/32.png) [@flashead](https://forum.kirupa.com/u/flashead)\
**Post date:** [May 27, 2011, 2:26pm UTC](https://forum.kirupa.com/t/character-in-3d-space-following-mousex/322630/1 "2011-05-27T14:26:54Z")

</div>

Hey All,

I’m a non-3D guy with a 3D problem to solve.

I have a character moving around in 3D space (his Z value is fixed, like a 2D side-scroller with 3D graphics). He’s supposed to follow the mouse. But because the mouse’s Z is not the same as the character’s, I obviously can’t just set his Z to that of the mouse.

I’m pretty sure I need to use the distance between the character and the camera when calculating the character’s new X position. But I’m not the mathiest person around, and the wiki article on 3D projection ([http://en.wikipedia.org/wiki/3D\_projection](http://en.wikipedia.org/wiki/3D_projection)) made me a little dizzy. All I know is I need to do the inverse of what that article describes.

I’m not using any 3D engines. I’ve found posts about certain versions of PaperVision that actually have a method built into the Camera class to do exactly this (Camera.unproject()). I’m going to attempt to dig into that to see if I can pull out the formula that I need. But in the meantime I thought I would pick the brains of you brilliant Kirupians.

Thanks!  
K
