🌐 Godot Multiplayer Chat System

Screenshot

A simple but powerful real-time chat application built with Godot Engine using ENetMultiplayerPeer for network communication.

GDScript License

🚀 Features

  • Host & Join: Create or join multiplayer sessions
  • Real-time Messaging: Send messages instantly across all connected clients
  • User Management: Automatic user detection and connection handling
  • Simple UI: Clean and intuitive user interface
  • Cross-platform: Works on all platforms supported by Godot

📋 Requirements

  • Godot Engine 4.x
  • Basic understanding of GDScript
  • Network connection for multiplayer functionality

🎮 How to Use

For Server (Host):

  1. Click the Host button to create a server on port 1300
  2. Wait for players to connect
  3. Start chatting!

For Client (Join):

  1. Click the Join button to connect to localhost:1300
  2. Wait for connection confirmation
  3. Start chatting with other players!

Sending Messages:

  1. Type your message in the text field
  2. Click the Message button or press Enter
  3. Your message will be broadcast to all connected players

🔧 Code Structure

Main Functions:

  • _on_host_button_pressed() - Creates and starts a multiplayer server
  • _on_join_button_pressed() - Connects to an existing server
  • _on_message_button_pressed() - Sends messages to all connected peers
  • add_user(id) - Handles new user connections
  • send_message(text, sender_name) - RPC function for message broadcasting
  • server_opened() - Sets up user identification after connection

Key Variables:

  • peer - ENetMultiplayerPeer instance for network communication
  • message - String variable for message storage
  • my_name - Exported string for player identification

🛠️ Setup Instructions

  1. Create a new Godot project
  2. Add a Node2D as your main scene
  3. Add the required UI elements:
    • Host button
    • Join button
    • Message button
    • MessageText (TextEdit/LineEdit)
    • MessageLabel (Label)
  4. Attach this script to your Node2D
  5. Connect the button signals to their respective functions
  6. Set the my_name variable in the inspector (optional)

🌐 Network Configuration

  • Default Port: 1300
  • Default Address: localhost (127.0.0.1)
  • Protocol: ENet (UDP-based)
  • Max Connections: Unlimited (ENet default)

🔮 Future Enhancements

  • Custom server IP input
  • User list display
  • Message history
  • Private messaging
  • Chat rooms/channels
  • User authentication
  • Message timestamps
  • Emoji support

🐛 Troubleshooting

Connection Issues:

  • Ensure both host and client are on the same network
  • Check firewall settings for port 1300
  • Verify Godot version compatibility

Message Not Sending:

  • Check if properly connected to server
  • Ensure RPC permissions are correctly set
  • Verify UI element names match script references

📄 License

This project is open source and available under the MIT License.


🌐 Godot Çok Oyunculu Sohbet Sistemi

Screenshot

Godot Engine kullanarak ENetMultiplayerPeer ile ağ iletişimi sağlayan basit ama güçlü bir gerçek zamanlı sohbet uygulaması.

GDScript Lisans

🚀 Özellikler

  • Sunucu Oluştur & Katıl: Çok oyunculu oturumlar oluşturun veya katılın
  • Gerçek Zamanlı Mesajlaşma: Tüm bağlı istemciler arasında anında mesaj gönderme
  • Kullanıcı Yönetimi: Otomatik kullanıcı algılama ve bağlantı yönetimi
  • Basit Arayüz: Temiz ve sezgisel kullanıcı arayüzü
  • Çoklu Platform: Godot’un desteklediği tüm platformlarda çalışır

📋 Gereksinimler

  • Godot Engine 4.x
  • Temel GDScript bilgisi
  • Çok oyunculu işlevsellik için ağ bağlantısı

🎮 Nasıl Kullanılır

Sunucu için (Ana Bilgisayar):

  1. Port 1300’de sunucu oluşturmak için Host düğmesine tıklayın
  2. Oyuncuların bağlanmasını bekleyin
  3. Sohbet etmeye başlayın!

İstemci için (Katıl):

  1. localhost:1300’e bağlanmak için Join düğmesine tıklayın
  2. Bağlantı onayını bekleyin
  3. Diğer oyuncularla sohbet etmeye başlayın!

Mesaj Gönderme:

  1. Mesajınızı metin alanına yazın
  2. Message düğmesine tıklayın veya Enter’a basın
  3. Mesajınız tüm bağlı oyunculara yayınlanacak

🔧 Kod Yapısı

Ana Fonksiyonlar:

  • _on_host_button_pressed() - Çok oyunculu sunucu oluşturur ve başlatır
  • _on_join_button_pressed() - Mevcut bir sunucuya bağlanır
  • _on_message_button_pressed() - Tüm bağlı eşlere mesaj gönderir
  • add_user(id) - Yeni kullanıcı bağlantılarını yönetir
  • send_message(text, sender_name) - Mesaj yayını için RPC fonksiyonu
  • server_opened() - Bağlantı sonrası kullanıcı tanımlamasını ayarlar

Anahtar Değişkenler:

  • peer - Ağ iletişimi için ENetMultiplayerPeer örneği
  • message - Mesaj depolama için String değişkeni
  • my_name - Oyuncu tanımlaması için dışa aktarılan string

🛠️ Kurulum Talimatları

  1. Yeni bir Godot projesi oluşturun
  2. Ana sahne olarak bir Node2D ekleyin
  3. Gerekli UI öğelerini ekleyin:
    • Host düğmesi
    • Join düğmesi
    • Message düğmesi
    • MessageText (TextEdit/LineEdit)
    • MessageLabel (Label)
  4. Bu scripti Node2D’ye bağlayın
  5. Düğme sinyallerini ilgili fonksiyonlara bağlayın
  6. Inspector’da my_name değişkenini ayarlayın (isteğe bağlı)

🌐 Ağ Yapılandırması

  • Varsayılan Port: 1300
  • Varsayılan Adres: localhost (127.0.0.1)
  • Protokol: ENet (UDP tabanlı)
  • Maksimum Bağlantı: Sınırsız (ENet varsayılanı)

🔮 Gelecek Geliştirmeler

  • Özel sunucu IP girişi
  • Kullanıcı listesi görüntüleme
  • Mesaj geçmişi
  • Özel mesajlaşma
  • Sohbet odaları/kanalları
  • Kullanıcı kimlik doğrulama
  • Mesaj zaman damgaları
  • Emoji desteği

🐛 Sorun Giderme

Bağlantı Sorunları:

  • Hem sunucu hem de istemcinin aynı ağda olduğundan emin olun
  • Port 1300 için güvenlik duvarı ayarlarını kontrol edin
  • Godot sürüm uyumluluğunu doğrulayın

Mesaj Gönderilmiyor:

  • Sunucuya düzgün bağlandığınızdan emin olun
  • RPC izinlerinin doğru ayarlandığından emin olun
  • UI öğesi isimlerinin script referanslarıyla eşleştiğini doğrulayın

📄 Lisans

Bu proje açık kaynaklıdır ve MIT Lisansı altında mevcuttur.


🤝 Contributing / Katkıda Bulunma

Feel free to fork this project and submit pull requests for any improvements!

Bu projeyi fork’layabilir ve iyileştirmeler için pull request gönderebilirsiniz!

📞 Support / Destek

If you encounter any issues or have questions, please open an issue in the repository.

Herhangi bir sorunla karşılaşırsanız veya sorularınız varsa, repository’de bir issue açın.