Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question FPS Controller issues with setting player position

Discussion in 'Physics' started by wztk, Aug 25, 2020.

  1. wztk


    Feb 25, 2020
    Hello guys,

    I'm currently developing a game using FPS controller from Standard Assets. It has a mode in which player needs to be constantly switching positions on a button press. At first I had problems with rotations, but those were fixed by modifying MouseLook.cs script. However, I still can't get position to work consistently for me. Sometimes (I'd say 1 in 4 attempts) the player warps to a location near to the Vector3 value but not at the precise point specified, almost as if it gets stuck at some point and decides not to move player any longer.
    What's stranger is that it seems to be only happening in editor - when it's built and deployed on Android it seems to work fine in 20-30 attempts that I've made. All I'm doing is a simple transform.position assignment as per example below:

    Code (CSharp):
    1. if (currentStage == 1)
    2.         {
    3.             mouseLook.LookRotation(playerObject.transform, cam.transform, 135, 0.01f); //modified mouseLook
    4.             playerObject.transform.position = new Vector3(-1.92f, 0.98f, -15f);
    6.         }
    I've tried to switch off CharacterController during position change as per suggestions to similar problems, but it hasn't helped.

    I'm out of ideas so if any of you has encountered similar problem, please share a solution.


    EDIT: I've done about 100 extra playthroughs on editor and on the phone just to be on the safe side, so far no issues on Android and editor still has them. Can't nail what's the issue, doesn't matter if I try to do it fast or slow, sometimes it's further away and sometimes it's closer.
    Technically it should work on Android just fine but I'm worried that if I ever decide to post it on iOS it will break or it's just one device case.

    I'm using Unity 2019.3.6f1.
    Last edited: Sep 18, 2020