I’m working on a movement system where the camera is constrained to a rail/spline while the player is able to move within the bounds of the camera view. However I’m having issues with getting the player to move relative to the camera view.
The diagram below shows my current setup.
At the moment I have everything setup so that the camera is attached via a springarm to a ‘dummy’ mesh that moves along the rail and the player (red cube) is a child of the camera that can move in the Y and Z axes within the bounds of a defined area of the camera view. However when the camera follows a curve round and in the direction of the X axes, the vertical movement of the player remains fine but the the horizontal movement remains locked to the world Y axes instead of rotating with the camera.
So I am looking for help in modifying my player movement to keep it relative to the camera. Basically what I’m looking to achieve is having the player move on a plane relative to the camera, represented in the diagrams below by the light blue plane, so that as the camera follows the curve of the rail/spline (A -> B) the player’s movement axes remain aligned to the camera rather than the world.
Does anyone have any suggestions as to how I could achieve this?
My current player movement is setup as shown below.