Hello,
I'm working on a 3D scroll shooter.
My main 3D World character is following a 2D screen point. I use that screen point to keep my character always within the screen-bounds. Now I need a calculation so that my keyboard forward direction is aligned with the 3d perspective view of the camera. Any ideas how to calculate this movement from my keyboard input axis and apply it to the 2d screen position?
EDIT:

The camera is moving 10 m/s in the z direction. Perspective cam, rotated 45 degree with a fov of 45. the 2d screen point is translated with the keyboard input axis. The character is following in 3D space the 2d screenpoint with the ScreenPointToRay Camera function. I want to translate my 2D point to match the camera perspective view.
Hope that this quick sketch do a better explanation.
EDIT:
I found some part of the solution.
private Vector3 movement = Vector3.zero;
private Vector3 position2D = Vector3.zero;
void Start ()
{
position2D = mainCamera.WorldToScreenPoint (thisTransform.position);
}
void Update ()
{
//Get keyboard movement axis
movement = new Vector3 (Input.GetAxisRaw ("Horizontal"), Input.GetAxisRaw ("Vertical"), 0);
if (!isMoving) {
Vector3 move = mainCamera.ScreenToWorldPoint (position2D);
move += new Vector3 (movement.x, 0, movement.y);
Vector3 direction = mainCamera.WorldToScreenPoint (move);
direction = direction - position2D;
direction.z = 0;
movement = direction.normalized * movement.magnitude;
StartCoroutine (...further calculation of position2D and movement...);
}
}
Peter.