CharacterController2D icon indicating copy to clipboard operation
CharacterController2D copied to clipboard

Warp to ground freeze Unity

Open gabry90 opened this issue 6 years ago • 2 comments

Hi, when call Warp To Ground method from other script in OnStart() function Unity freeze always after click play game.

During some debug i'll found the problem. In the while loop the movement still continue infinitly with IsGrounded always false.

This problem occur only when in the Unity Project settings Physics2D AutoSyncTransform is set to False. If turn it to True the problem not exists. But, i need to turn off this settings for some reasons in my project.

Thanks

gabry90 avatar Apr 17 '19 13:04 gabry90

I feel like the function is dangerous. If there is no ground (e.g void chasm) then it looks like the program will just freeze if called.

Either that, or if there's void below and platform above, it could freeze for a while and then the player eventually warps upwards due to underflow, which would be very confusing to both players and devs.

Might want to try code around that by explicitly checking whether moving downwards exceeds some lower boundary.

AkashaP avatar Sep 01 '19 02:09 AkashaP

That is a good call. Perhaps if the method took in a maximum distance to check it could add a safety net. It’s main purpose was actually for an in-game editor that always had a ground underneath so there was never a worry of hitting the infinite loop.

prime31 avatar Sep 01 '19 02:09 prime31