GODOT_FUNCTION
Usage
GODOT_FUNCTION();
void function_name(int p_param);
Expose the following function as a method to scripts. Via the parameters the function can additionally be bound as a virtual or a rpc method.
The return type and all parameter types must be Godot Variant compatible.
You can also bind the function with a different name by providing a string literal argument in the attribute.
GODOT_FUNCTION("exposed_name");
void internal_name(int p_param);
Available Parameter Types
GOC_Virtual
This parameter type is used to set if this function is overwritable in scripts within the GODOT_FUNCTION macros body.
The following values are available:
Value |
Description |
|---|---|
NoVirtual |
This function will not be bound as a script virtual function and can not be overwritten in scripts. |
ScriptVirtual |
This function will be bound as a script virtual function and can be overwritten in scripts. The bounds virtual name will be _<function_name>. When called from within the extension this method can be used to call the script virtual function if it exists, otherwise this function will be called. |
ScriptVirtualRequired |
This function will be bound as a script virtual function and must be overwritten in scripts. The bounds virtual name will be _<function_name>. When called from within the extension this method can be used to call the script virtual function if it exists, otherwise this function will be called and an error is displayed. |
GOC_RpcMode
This parameter type is used to set the functions rpc mode within the GODOT_FUNCTION macros body.
The following values are available:
Value |
Description |
|---|---|
Disabled |
This function cannot be called via RPC in the high-level multiplayer api. This is the default value. |
AnyPeer |
When used in the high-level multiplayer api any peer can call this function without permission. |
Authority |
When used in the high-level multiplayer api only the current authority of the target node can call this function. |
GOC_RpcSync
This parameter type is used to set the functions rpc sync behavior within the GODOT_FUNCTION macros body.
The following values are available:
Value |
Description |
|---|---|
CallRemote |
When called via RPC, this function will only be called on the remote peer. |
CallLocal |
When called via RPC, this function will be called on both the remote peer and locally. |
GOC_TransferMode
This parameter type is used to set the functions rpc transfer mode within the GODOT_FUNCTION macros body.
The following values are available:
Value |
Description |
|---|---|
Unreliable |
Packets are not acknowledged, no resend attempts are made for lost packets. Packets may arrive in any order. Potentially faster than “UnreliableOrdered”. Use for non-critical data, and always consider whether the order matters. |
UnreliableOrdered |
Packets are not acknowledged, no resend attempts are made for lost packets. Packets are received in the order they were sent in. Potentially faster than “Reliable”. Use for non-critical data or data that would be outdated if received late due to resend attempt(s) anyway, for example movement and positional data. |
Reliable |
Packets must be received and resend attempts should be made until the packets are acknowledged. Packets must be received in the order they were sent in. Most reliable transfer mode, but potentially the slowest due to the overhead. Use for critical data that must be transmitted and arrive in order, for example an ability being triggered or a chat message. Consider carefully if the information really is critical, and use sparingly. |
GOC_RpcChannel
This parameter type is used to set the functions rpc channel within the GODOT_FUNCTION macros body.
The following values are available:
Value |
Description |
|---|---|
Channel |
Sets this functions rpc channel when used with the high-level multiplayer api. |