Player snaps back after loading into correct place

Like other users, I’m also having the issue of the player being placed in the default position. However, because I’m using character controller and not NavMeshAgent, turing NavMeshAgent off and on again doesn’t work here unfortunately.

I added a 0.5f second delay after getting the spawn point before updating the player position which explains the delay after loading the new zone, but as you can see, it updates the player to the spawn point for 1 frame before snapping back to the default position. Any Ideas?

Thanks

Link to the video Loading zone position glitch - YouTube

Edit: I should also mention that this happens 60% of the time.

There are 3 outcomes: Player moves correctly, Player moves and snaps back (like above), and Player doesn’t move at all (not even to the default position)

Most of my ideas involve using the NavMeshAgent, so no guarantees here.

From a search on teleporting characterControllers, I found that CharacterControllers do not like to be warped about. However, the same trick we use with the NavMeshAgent should work with the CharacterController

characterController.enabled=false;
transform.position = targetPosition;
characterController.enabled=true;

At this point, the CharacterController should wake up and grab the new position of the player.

Brian, you beautiful man, you’ve done it again!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms