How do I deal with consecutive ' Condition Math::is_nan(x.v) is true ' error reports?

TentaTenta Posts: 8Member

Hello, I am currently working on a 2.5D Action Platformer for mobile devices.

Recently I have encountered an issue where whenever I call move_and_slide in my player's script '', an error is logged:
Condition ' Math::is_nan(x.v) ' is true

Whenever this error is printed the character seems to think that the platform is right beneath it.
Interestingly, this collision still happens no matter if the character's collision mask and the platform's collision layers do not overlap.

If necessary, here is a GitHub link to the code, the most relevant build is in the rebuild branch:

Thank you

Tags :


  • MegalomaniakMegalomaniak Posts: 2,493Admin

    on line 40 theres a Vector3.UP

    Any chance you have been copy-pasting code from a unity project?

  • TentaTenta Posts: 8Member

    @Megalomaniak said:
    on line 40 theres a Vector3.UP

    Any chance you have been copy-pasting code from a unity project?

    No no
    While I do come from a Unity background, this project was built from the ground up in Godot using only GDScript, while referring only to Godot's official docs and guides pertaining to the engine specifically.

    Looking at the docs where a KinematicBody is used, use pass in Vector3(0, 1, 0) for which Vector3.UP is a shorthand for, and they encounter no issues.

  • MegalomaniakMegalomaniak Posts: 2,493Admin
    edited June 2019

    Ok, never used the shorthand, or even looked for one which is why it stuck out to me I guess.

    edit: the error looks to be coming from the update_contacts() in

    Does the error only occur if there is nothing to slide on perhaps?

    func update_contacts() -> void:
        if get_slide_count() <= 0:

    If so then this bit might be the cause. I don't remember which issue but I seem to recall someone having some issue with physics where they added a return value to fix their issue. This is pretty much as good as a blind guess on my part though. Haven't dealt with physics much personally(more of a graphics/shaders guy myself).

  • MegalomaniakMegalomaniak Posts: 2,493Admin

    Ok, so far as I can tell the typical cause for Math::is_nan(something.other) is true error WRT physics related issues tends to be a division by zero happening somewhere.

    By chance might any of your nodes somehow get scaled to 0?

  • TentaTenta Posts: 8Member

    I've checked the seen while it is running and none of my assets, relevant or otherwise, ever get scaled to 0
    However, I have found that the player's translation data immediately gets set to nan on start up of the application.

  • TentaTenta Posts: 8Member

    Issue's been resolved.

    Turns out I was moving the player's connected collision shape to weird position so in actually it was something completely unrelated to move_and_slide

  • MegalomaniakMegalomaniak Posts: 2,493Admin

    Glad to hear it! :)

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file