I know there are a million other questions like this here, so sorry for being an idiot. Here goes:
My character is a RigidBody ball, and I have this:
( "a < b" would mean that a is the parent of b)
Ball < GameObject < Camera
Ball has a simple movement script attached.
GameObject has a script to stop it from rotating when Ball does.
Camera has a camera movement script.
Everything works right, except that the movement of Ball is not camera relative. Pushing forward always results in movement in one direction, regardless of which way the camera points.
The complicating factor is that I can't simply make the y rotation of Ball equal to that of the Camera, because that would effect the physics (if you hit a wall while spinning the camera you would bounce off differently).
So how do I make movement of my character relative to camera direction without rotating my character on the y axis when the camera turns?
JavaScript please!!!!
My movement script:
var speed : float = 6.0;
private var RotDirection : Vector3 = Vector3.zero;
function FixedUpdate () {
RotDirection = Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
RotDirection *= speed;
rigidbody.AddTorque (RotDirection);
}