Add default parameters value in C++

Godot Version

4.2

Question

Hi
after creating a method I put the default value but inside Godot does not exist.
any solution?

public:
    void test(String s = "");

In your bind methods do something like this

ClassDB::bind_method(D_METHOD("send_bytes", "bytes", "id", "mode", "channel"), &SceneMultiplayer::send_bytes, DEFVAL(MultiplayerPeer::TARGET_PEER_BROADCAST), DEFVAL(MultiplayerPeer::TRANSFER_MODE_RELIABLE), DEFVAL(0));

2 Likes

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