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

TentaTenta Posts: 8Member
in 3D

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 'multi_form_char.gd', 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:
https://github.com/TiGBS/Guul/tree/rebuild

Thank you


Tags :

Answers

  • MegalomaniakMegalomaniak Posts: 1,585Admin

    on line 40 theres a Vector3.UP

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

    https://docs.godotengine.org/en/3.1/classes/class_vector3.html

  • TentaTenta Posts: 8Member

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

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

    https://docs.godotengine.org/en/3.1/classes/class_vector3.html

    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: 1,585Admin
    edited June 13

    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 base_char.gd

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

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

    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: 1,585Admin

    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: 1,585Admin

    Glad to hear it! :)

Leave a Comment

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