0 votes

I am currently working on 2d card trading multiplayer game ( 4 Players ). The game consists of 4 Players sitting round a table and get equal amount of cards, shuffled. The cards in the game are loaded from a JSON file with image paths, id, suit type, etc. and then are stored in an array ( allInstances = [] ).

I implemented a function namely loadCardData() for the card loading process and a function chunk() that splits the allInstances array into 4 equals ( 52 cards = 4 * 13 ) inside an array named chunked_arr[]. Function loadCardData() contains a randomize function that shuffles the position of cards which is good, but it jumbles the cards for every player in every peer and all the player gets different cards in all the connections which is not desired i am desiring a single player let's say Player to have same type of cards in all the peer connection. So i instead added a condition to the script

if get_tree.is_network_server():
    loadCardData()      # Load Cards into allInstances 
    chunk(allInstances, 13)    #split array into equals and store in 

But this does work for the server as chunkedarr get data but the clients chunkedarr seems to store no data. How should i go about passing the chunked_arr data to the clients.

in Engine by (44 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.