I’ve run into a rather frustating problem today while doing some tests. I’m working on a physics based platformer, where movement is carried out by passing Vector3 to the player character and having them move towards the vector3 Via Rigidbody.AddForce. This is all well and good but this morning I’m trying to translate that system in to one where the player ignores normal gravity and has their gravity affected by a planetoid, this is where all of the problems start to crop up. Normally to find the Vector3 along which to move the player, I plug the input on the X and Y axis’s into something like this:

```
void GrabInput(){
x = Input.GetAxis ("Horizontal");
y = Input.GetAxis ("Vertical");
direction =(relMoveRight * x) + (relMoveForward * y);
target = direction + transform.position;
crossHair.position = target;
}
void OrientAxis(){
relMove = Quaternion.Euler(new Vector3(0f,mainCam.eulerAngles.y,0f));
relMoveForward = relMove * Vector3.forward;
relMoveRight = relMove * Vector3.right;
}
```

And Here is the Code Dictating the cameras movement:

```
void Update(){
mainCam.rotation = Quaternion.Slerp (mainCam.rotation,CamRot(),smoothing*Time.deltaTime);
mainCam.position = Vector3.Lerp (mainCam.position, CamPos(), smoothing * Time.deltaTime);
}
Quaternion CamRot(){
Quaternion newRot = Quaternion.identity;
newRot = Quaternion.Euler(camY,camX,0f);
newRot = transform.rotation * newRot;
return newRot;
}
Vector3 CamPos(){
Vector3 newPos = Vector3.zero;
newPos = (CamRot () * new Vector3 (0f,0f,-zoom)+transform.position);
return newPos;
}
```

So as you can see, i make sure that the movement is relative to the Cameras Y rotation. The part i’m running into trouble with is to basically find the local equivalent of this line here:

```
relMove = Quaternion.Euler(new Vector3(0f,mainCam.eulerAngles.y,0f));
```

I’ve messed around with various conversions such as transform.InverseTransformDirection and Quaternion.Inverse but have had no luck so far.

Any help would be greatly appreciated!