I have a ball and I can use WASD or arrow keys to move the ball. The ball rolls to the direction I press, rotating to left, right, forward, or backward. I want a camera to follow the ball. The camera should have Z rotated to 34 approx, facing the ball up in the air. I want to move the camera only when I move my mouse to the left or the right, when i change direction of ball. Here is what I have so far:
private void FixedUpdate()
{
if(referencedCamera != null)
{
float miscaOrizontal = Input.GetAxis("Horizontal");
float miscaVertical = Input.GetAxis("Vertical");
Vector3 miscare = referencedCamera.transform.TransformDirection(
new Vector3(miscaOrizontal , 0.0f ,miscaVertical ) );
rigidbody.AddForce(miscare * viteza * Time.deltaTime);
Debug.Log("speed"+ miscare);
}
}