I’m working on a multiplayer P2P game.
I select my nuke button and it creates the cursor image to drag to where I want the nuke to land and when I release the mouse it places a object (target) to where the nuke should goto. It places it on both game windows. I then should create the nuke and move it to the target.
But whats happening is on one game window it fires the nuke to the target and the other game window it fires it towards the top/left like theirs no target. I true separating the event into two and even placed the move action with the condition that theirs a target in place to above the create event. Tried both towards object and the cords of the object. It does this with a permanent force. When i replaced the trigger once condition with a number of nukes = 1 condition it does the same. Because the object gets destroyed when it leaves the field a new nuke will get created and then moves to the target. It seems that something is happening that cause the nuke and target both to be created but the position of the target is not yet registered in the engine. I was able the rectify my problem with having the event separated into two and using a instant force instead of a permanent force. Also want to point out the bug does not always happen but does the majority of the time.
I’m working on a multiplayer P2P game.
Sound like the target co-ordinates aren’t being received. Maybe focus on why that’s happening?
Yes, it sounds like targetRedPlace doesn’t have coordinates, but how can their be a object but not X and Y coordinates for it? It has to have a position when it’s placed. It has to be their for it to activate the action. That’s why I have the condition “The number of targetRedPlace objects = 1” So it shouldn’t even create the nukeRed object until that condition is met. That’s the problem. I tried a number of things to get this to work, even putting the action to apply a force to nukeRed before its created with a condition that both the redNuke and targerRedPlace is = 1. But I placed it both before and after the event. I used both the object it’s self and “ToString(targetRedPlace.X())” using the Add a force to move toward a position. same results as using “Add a force to move toward an object action”.
The example below shows this the action shows the that the nuke should be made with the target in place as a condition, and then the next frame should cause it to move with a second check to make sure that condition is met. So I’m confused on your response. Seems to me a glitch in the engine itself.
You’re doing P2P, right? So what information are you passing? How do you tell the peer there’s a targetRedPlace and what its co-ordinates are?
Ok so I removed all the other game events to focus on just this issue. Yes I’m new to the P2P aspect and struggle with it. But I do see now why its doing this, but don’t know how to really fix it properly.
heres the screenshots. Their is a event thats disabled as I just tested something. Unfortunately What I disabled only works sometimes. Seems like too much of a delay for whats disabled to work right and causes it to only work sometimes, but that explains why the permanent force didn’t work. I just can’t figure out how to better handle this. The way I did it does render the targetRedPlace right away visually but apparently the code runs faster then what I was seeing I even throw a Pause game execution event in right after the object was created and it always showed it is the proper location which threw me off I would have thought it would have placed it at x-0,y-0 with the pause execution to see that but didnt, kept showing it in the proper spot. Surly theirs a better way of doing this then what I came up with, I just can’t seem to figure it out for some reason. This must be the same issue I had with tring to do the same with tower placement which I had to address completely differently then I wanted too. What am I doing wrong or missing?
I haven’t used P2P with GDevelop, so I’m only hypothesising here.
How can yo be certain you receive the RedNuke event before the plrRedposX and plyRedposY events? Just because they are sent in that order, doesn’t mean they get received in that order. This may also explain the issue not always occurring…
Why don’t you send the X & Y co-ordinates as extra data to the RedNuke event - say like
ToString(tagetRedPlace.X() + "|" + ToString(targetRedPlace..Y(), and then strip the 2 parts in the receiving event? Then all the info is in one package and one event. No need to worry about the order it arrives in.