Moving an object with the camera

So I have an object I’d like to move so that it follows the camera as the player looks around. The problem is that I’m trying to move it in 2D, along the Z-X plane. Think of it almost like sliding a puzzle piece around on the table top but without lifting it up (no Y direction movement). I still want to keep it in the center of the camera, but on the Z-X plane.

I thought about just making a really big plane and doing a single line raytrace from the camera to see where on the plane it intersects and then moving the object to that point every update call, but I feel like there’s probably an easier way than that.

I feel like I can just use Set Actor Location but I’m not sure how to map camera rotation to Z-X movement to get the effect I want. I want the object to follow along at the center of the camera. Hopefully someone has an idea.

There are a bunch of ways to do it. Do you need it to actually project onto the ground, so that the distance the object is from the camera depends on where you aim? Ie when aiming down the object is at your feet and as you look up it moves to the horizon eventually off to infinity (or clamped if you want that). If you want the above behavior a line trace may not be bad way to go.

If you just want it to position based on camera direction with a fixed offset distance you could simply use “SetWorldLocation” and get the player(or camera) location and add “camera forward vector * DISTANCE” where distance is a param to control distance. “camera forward vector” could come from “Get player controller” → get actor rotation-> get rotation Xvector or any other overriding camera values from a camera BP if there are any.

I do actually have to project onto the wall, since the puzzle piece cannot be moved off of the wall, so your first example is more accurate. The problems with a distance offset is that, as the camera rotates, you get a circular motion so eventually you get movement in the Y direction.

I’ll go with the ray trace then. I was just curious if anyone else had ideas since it seemed a bit complicated a method for something as simple as movement along a plane