diff --git a/modules/enet/doc_classes/ENetPacketPeer.xml b/modules/enet/doc_classes/ENetPacketPeer.xml
index 3171da1f6db..659cea974c9 100644
--- a/modules/enet/doc_classes/ENetPacketPeer.xml
+++ b/modules/enet/doc_classes/ENetPacketPeer.xml
@@ -18,6 +18,12 @@
Returns the number of channels allocated for communication with peer.
+
+
+
+ Returns the ENet flags of the next packet in the received queue. See [code]FLAG_*[/code] constants for available packet flags. Note that not all flags are replicated from the sending peer to the receiving peer.
+
+
diff --git a/modules/enet/enet_packet_peer.cpp b/modules/enet/enet_packet_peer.cpp
index edb33fc96b9..9ec68465a5d 100644
--- a/modules/enet/enet_packet_peer.cpp
+++ b/modules/enet/enet_packet_peer.cpp
@@ -175,6 +175,11 @@ int ENetPacketPeer::get_channels() const {
return peer->channelCount;
}
+int ENetPacketPeer::get_packet_flags() const {
+ ERR_FAIL_COND_V(packet_queue.is_empty(), 0);
+ return packet_queue.front()->get()->flags;
+}
+
void ENetPacketPeer::_on_disconnect() {
if (peer) {
peer->data = nullptr;
@@ -206,6 +211,7 @@ void ENetPacketPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("send", "channel", "packet", "flags"), &ENetPacketPeer::_send);
ClassDB::bind_method(D_METHOD("throttle_configure", "interval", "acceleration", "deceleration"), &ENetPacketPeer::throttle_configure);
ClassDB::bind_method(D_METHOD("set_timeout", "timeout", "timeout_min", "timeout_max"), &ENetPacketPeer::set_timeout);
+ ClassDB::bind_method(D_METHOD("get_packet_flags"), &ENetPacketPeer::get_packet_flags);
ClassDB::bind_method(D_METHOD("get_remote_address"), &ENetPacketPeer::get_remote_address);
ClassDB::bind_method(D_METHOD("get_remote_port"), &ENetPacketPeer::get_remote_port);
ClassDB::bind_method(D_METHOD("get_statistic", "statistic"), &ENetPacketPeer::get_statistic);
diff --git a/modules/enet/enet_packet_peer.h b/modules/enet/enet_packet_peer.h
index fe40d061882..b41d67e86b4 100644
--- a/modules/enet/enet_packet_peer.h
+++ b/modules/enet/enet_packet_peer.h
@@ -113,6 +113,7 @@ public:
double get_statistic(PeerStatistic p_stat);
PeerState get_state() const;
int get_channels() const;
+ int get_packet_flags() const;
// Extras
IPAddress get_remote_address() const;