Player disappears randomly when colliding with tilemap (solved)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Bananacrabman

I’m building a simple 2D platformer using a tilemap and a character node that utilizes move_and_slide() for movement. For some reason when the player collides with certain tiles in a certain way it disappears from the scene. After some testing I’ve figured out that that player is still in the scene tree but when i check its position it gives me a Vector2 with the values (nan,nan).

I’m not entirely sure what is causing this to happen but my thinking is it has to do with the collision between the player and the tiles. i did a test where all the tiles were box shaped and i couldn’t get the player to disappear then but it is not the easiest bug to replicate and i may not have tested for long enough.

I’ve provided a link to the project bellow if anyone wants to give it a shot for themselves, as well as an image showing an area where i have been able to more successfully get the bug to occur, thank you for your time.

Link to project

:bust_in_silhouette: Reply From: Bananacrabman

I figured out the issue, It had to do with how i was organizing my jump and fall state the way i had it set up was not efficient and when the fall state was entered if the values weren’t right it would send the player to no mans land.