Rotate Camera Around Moving Sphere?

Hey guys, I’m sorry to have to ask this, but I’ve looked all over to try to accomplish this;

I have a moving sphere, it moves via torque and force, I have a camera I can rotate around the ball with using my mouse (though I will eventually want it to be via touch joystick) but I need ball to move forward according to the camera.

Right now if I push forward and the camera is turned say 90 degrees, the ball will still behave as though the camera had not moved and continue on it’s original “forward direction”, can anyone solve this for me?

Below are the two scrips I’m using:

Attached to camera:

using UnityEngine;
using System.Collections;


public class FixedDistanceFromPlayer : MonoBehaviour {

	public float turnSpeed = 4.0f;
	public Transform player;

	public float height = 1f;
	public float distance = -2f;
	
	private Vector3 offsetX;
	private Vector3 offsetY;
	
	void Start () {
		
		offsetX = new Vector3 (0, height, distance);
		offsetY = new Vector3 (0, 0, distance);
	}
	
	void LateUpdate()
	{
		offsetX = Quaternion.AngleAxis (Input.GetAxis("Mouse Y") * turnSpeed, Vector3.up) * offsetX;
		offsetY = Quaternion.AngleAxis (Input.GetAxis("Mouse Y") * turnSpeed, Vector3.right) * offsetY;
		transform.position = player.position + offsetX; 
		transform.LookAt(player.position);
	}
}

Attached to player (sphere):

using UnityEngine;
using System.Collections;

public class PlayerControl : MonoBehaviour {

	public float acceleration = 200.0f;
	public float force = 20.0f;
	public float jumpPower = 5.0f;


	void Start () {
		rigidbody.maxAngularVelocity = 100.0f;
	}
	
	void FixedUpdate() {
		float horizontalMotion = -Input.GetAxis("Horizontal");
		float verticalMotion = Input.GetAxis("Vertical");
		Accelerate(verticalMotion, horizontalMotion);
		
		if (Input.GetButton("Jump") && IsGrounded()) {
			Jump();
		}
		Vector3 movement = (Input.GetAxis("Horizontal") * -Vector3.left * force) + (Input.GetAxis("Vertical") * Vector3.forward *force);
		movement *= Time.deltaTime;
		rigidbody.AddForce(movement, ForceMode.Acceleration);
		//transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, Camera.main.transform.localEulerAngles.y, transform.localEulerAngles.z); 
	}

	void Accelerate(float forward, float sideways) {
		Vector3 torqueVector = new Vector3 (forward, 0, sideways);
		rigidbody.AddTorque (torqueVector * acceleration, ForceMode.Acceleration);
		//transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, Camera.main.transform.localEulerAngles.y, transform.localEulerAngles.z); 
	}

	bool IsGrounded() {
		int notPlayerMask = ~(1 << 8);
		Vector3 aBitBelow = -Vector3.up*0.05f;
		bool onGround = Physics.CheckSphere (transform.position + aBitBelow, 0.5f, notPlayerMask);
		return onGround;
	}

	void Jump() {
		Vector3 newVelocity = rigidbody.velocity;
		newVelocity.y = jumpPower;
		rigidbody.velocity = newVelocity;
	}
}

The two parts I’ve commented out of the player script is what I’ve tried most recently.

And just so you know, no my player is not a child of the camera

Thank you to anyone who can help me with this, it’s very much appreciated!

You can just replace the Vector3 movement line in your code with this one:

Vector3 movement = (Input.GetAxis("Horizontal") * Camera.main.transform.right * force) + (Input.GetAxis("Vertical") * Camera.main.transform.forward *force);

This will make your ball move according to your camera’s rotation.