|
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:
(comments are locked)
|
|
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
(comments are locked)
|
|
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.
(comments are locked)
|

Thanks, Dave A.
Basically I detect if the user is swiping to the right, left, up, or down. Then, if he is swiping to the right, I move the character in the Vector.right direction. But I'm guessing that Vector.right is w.r.t the direction of the camera, and not the character?
Please post code.
I added some.