iOS swipe movement

I’m doing some very simple movement. I have a character that is standing in the middle of a scene. If the user swipes to the right, the character moves to the right until he hits an obstacle.

When I test this in the Unity editor, all movement works fine. I just call Move() on the CharacterController and pass it the movement vector (which is either Vector.forward/.back/.right/.left).

But when I run it on my iOS device, it is as if the movement vector is relative to the camera location instead of the character. For example, if I call Move(Vector.forward), the character moves up into the air instead of “forward” in the scene.

Does this make sense? What am I missing? Here is some code:

    CharacterController controller = GetComponent<CharacterController>();
    float dX = Mathf.Abs(touchPosition.x - startTouchPosition.x);
	float dY = Mathf.Abs (touchPosition.y - startTouchPosition.y);
	if (dX > dY)
	{
		if (touchPosition.x > startTouchPosition.x)
			controller.Move(Vector3.right * Time.deltaTime);				
		else// if (touchPosition.x < startTouchPosition.x)
			controller.Move(Vector3.left * Time.deltaTime);
	}
    etc...

Vector3.forward is world-coordinate forward. To move a character forward from the character’s perspective, you probably want controller.transform.forward.

http://unity3d.com/support/documentation/ScriptReference/Transform-forward.html

Probably going to need more info. How are you detecting gestures on the device? My stab-in-the-dark guess is, you are detecting x,y movement on screen, and applying that to the x,y of the character. Not x,z.