Biscotto's Forum Posts

  • Can you show, even with a simple screen, the part of the events you are referring to?

  • I think I was able to solve it.

    The problem was not in my functions, but in the way C3 synchronizes the objects. The Player object that was specified as the object to keep synchronized with the peer, was not always created in the same sequence. In practice, I noticed that although Player1 was always created first in the host, when the instances were synchronized in the peer, Player2 was often created first.

    Currently, however, I think I have solved everything by setting the sending phase of the various data by step. Each time all the objects have been created correctly in the peer, the peer sends a message to the host to indicate that everything has been created, and consequently the host proceeds to send the rest of the data.

    Thanks for your answers though! ^^

  • Is there a specific tutorial that covers instances in events that you can point me to?

    Within the editor there are many tutorials in the "Beginner" section that can help you understand how construct works.

    This is simple tutorial that might help you: editor.construct.net

  • When an instance is created, C3 identifies it with a UID and IID. For example, you can make a pick of an instance using the appropriate event by referring to its UID.

    Here is the link to the manual page where it is explained what an instance UID and IID is: construct.net/en/make-games/manuals/construct-3/project-primitives/objects/instances

  • You do not have permission to view this post

  • As for my first problem, I solved it by sending a single message at the end of the loop in JSON string format. This way I avoided sending messages to the peer for each loopindex. Sending each message with a tag based on the loopindex would have been very difficult since if I have a 10x10 grid I would have had to hand write 100 ifs to make the peer perform the correct action for each message tag received.

    My big problem that I can't solve/understand now is the one mentioned in my last post.

    It seems that during message exchanges the two apps lose their synchronization....

    When a message with a certain tag is received, can it be overwritten by another message with a different tag received shortly after?

    As you can see from the last screen, I created a "dialogue" of messages with "pg" tags between host and peer so that one sends data to the other only after receiving the right information from the other. In this way I thought to avoid loss or lack of data, but it doesn't seem so. By removing the 0.01 sec "waits", the problem seems to occur more frequently.

  • Don't use alert or anything else that waits when receiving network messages. It means that while it's waiting, other messages can arrive and overwrite the current message. It should always work fine if you avoid alerts/waits.

    I continued to experiment with the functionality of the Multiplayer object, and found another problem that was a bit stranger than the one in the previous posts.

    I'm attaching an image so you can better understand my situation:

    (the two functions set variables and create objects. They don't have any event of "Wait" or similar)

    The events you can see are executed only by the peer, and the various events of sending messages to the host are executed when your Player objects have been correctly created (the sub-event of the "On created" event is executed only when the second Player object (there are 2 Player objects in total) is created.

    The problem occurs randomly, as some times everything is executed correctly, while others I've noticed two types of errors occurring randomly and separately:

    - In the first sub-event, the two functions are not executed, but the "pg" message is still sent.

    - In the event of receiving the "pg" message from the host the Player pick is not executed because through an Alert of Player.Count the result is 1 (this should not be possible since the previous message of the above event is sent only if the second Player has been created)

    By inserting those two "Wait" events it seems that the errors occur less times, but still they occur very often.

    Since some times the code works correctly, I can't figure out where the error is and what it is caused by.

    I thought that the ids present in the Multiplayer object sometimes were not correctly accessible, and I tried to save them in a variable, but the result did not change, so the problem does not lie there. I have also checked several times that the Player.peerID variables are correctly assigned, and each time the variables are correct.

    Finally, I would like to point out that every time the problem occurs, both Players are on screen correctly, although a few times the Alert with Player.Count returned me the value 1.

  • Basically you want to use an image that you used on Construct within your site's CSS file?

    In this case the answer is yes. After you have exported the game to HTML5, you will have all the folders/files of your game available. You can then access the folder path where the image you want is located, and use it in any line of code on your site.

  • You can go either way.

    If you want to use the Advance Random object then you can use its "Probability tables".

  • I understand, so my suspicions were right.

    If I need to insert a wait between one message and another with the same tag, I must necessarily save all the values in a list first, and then run each message by cycling through the created list. Right? Or are there better methods?

  • I was testing all day to figure out where the problem was, but I couldn't.

    However, I made a discovery: if when the peer receives a series of messages, it has in its message receive event an Alert, only the first Alert is correctly displayed with the right Multiplayer.Message, the other Alerts, are all read with the content of the last received Multiplayer.Message.

    If the Alert is removed, everything seems to work correctly.

    Since my explanation is not very clear, I have modified the official C3 chat example to reproduce this problem. Just go to the Peer window, select the text field and press Enter. It will automatically send 10 messages to the host via a for loop.

    File: dropbox.com/s/fo11q00fwsjihux/Multiplayer%20chat%20example%281%29.c3p

    Sorry to tag you Ashley, but I think only you can give me a correct answer and help me.

    Thanks in advance!

    Edit:

    I understand that if I insert some particular event (like "Alert" or "Wait" events) into the read event of the message sent by the host, the event fails to queue and read more than one message properly.

    Is this normal or a bug? If this is normal, is it possible to understand why and how can I work around this problem? For example, if I want to insert a wait between the execution of multiple messages with the same tag, how can I do that?

  • Happy to have helped you!

    Be careful when using the IID of an instance. If for some reason you destroy one, and then create another in the usual location, your colors will no longer be ordered as they are in the JSON file. ;)

    Happy programming!

  • To keep your layout centered within the window/screen, I also recommend that you check the "Unbounded scrolling" property.

    Obviously you must also set the Fullscreen mode property, according to your needs.

  • I'm doing my first tests with the Multiplayer object of C3, so I'm not very expert with its functioning.

    At the moment of the connection between host and peer, the host creates a grid of instances of block object. I would like the connected peer to in turn create the same grid following the same pattern as the host's grid.

    So I thought of sending a message to the peer with the data of each block to make it create it in the same position:

    The problem is that the peer correctly receives the coordinates of the first block, and then receives a number of messages equal to the entire host loop, containing the coordinates of the last block of the grid, i.e. the last block created by the for loop.

    At this point I can't understand if C3 is able to send messages correctly in a short time. Or rather: the messages are sent, but the values inside are not updated correctly.

    Can anyone tell me where I'm wrong or if there is a better method to recreate the same object partner for both host and peer?

    Thanks!

    Tagged:

  • For the random number from 1 to 5, you need to modify your code. The solutions are different. You can solve with floor(random(1, 6)). This will correctly generate an integer number between 1 and 5.

    The numbers are random, so it may be that sometimes the number 3 is repeated many times.

    If you want to avoid this, before creating the power up, you could insert a control event: if there are already 3 balls of a certain power up, then create a ball of the opposite power up.

    I hope this helps you.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads