# Move ball player relative to camera rotation

I am working on a game where the player controls a free moving and rotating ball. I am unable to determine the Vector the player needs to correct to when the camera has been rotated. I can’t make the camera a child of the player because is would follow its every rotation. What I think I have to do is edit my player’s movement vector based off of the angle the camera is facing the player from.

What should I do to fix this problem?

Here is the code for the camera at the moment:

``````    private Vector3 offset:

public GameObject target;

float RotateSpeed = 3.0f;

void Start()
{
offset = gameObject.transform.position - target.transform.position;
}

private void FixedUpdate()
{
if (Input.GetKey(KeyCode.Q))
{
Quaternion turnAngle = Quaternion.AngleAxis(-RotateSpeed, Vector3.up);

offset = turnAngle * offset;
}
else if (Input.GetKey(KeyCode.E))
{
Quaternion turnAngle = Quaternion.AngleAxis(RotateSpeed, Vector3.up);

offset = turnAngle * offset;
}

gameObject.transform.position = target.transform.position + offset;
}

void Update()
{
gameObject.transform.LookAt(target.transform);
}
``````

And here is the current code I have on the player, excluding my attempts to correct the problem:

``````    public int speed;

private void FixedUpdate()
{
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");

Vector3 playerDirection = new Vector3(h*speed,0,v*speed);

//this if statement freezes the ball for the player by pressing X.
if (Input.GetKey(KeyCode.X))
{
Rigidbody rb = gameObject.GetComponent<Rigidbody>();

rb.velocity = new Vector3(0, 0, 0);
}
}
``````

``````    Vector3 RotateWithView(Vector3 direction)