View MFA
That formula should work...
Someone want to help me figure out why it doesn't always go where it should? Hopefully its pretty straight forward what I'm looking for - I want the "Actual X/Y" to be the same as the "New X/Y"


View MFA
That formula should work...
Someone want to help me figure out why it doesn't always go where it should? Hopefully its pretty straight forward what I'm looking for - I want the "Actual X/Y" to be the same as the "New X/Y"




I don't completely understand what's going on, but I managed to isolate a collision (see attached file) that makes it bug so hopefully you can debug it. I set their starting angles and positions. It seems to happen when they are moving in different directions as the change occurs... but just a hunch.
What is the every 1 second meant to be there for? Is that to simulate lag? It seems to be fine if you remove that.
Also, make sure you untick "Destroy object if too far from frame" for the red 'ball'. Just so you can see what happens when it does bug.
I'm pretty sure it's something to do with mixing "current" values and "past" values. I don't think the code factors in the ball colliding with walls and I think that's a problem:
Eg. Ball crosses line, hits wall and turns around, 1 second passes and the red ball is placed at the green ball however its calculations are not correct because the green ball was not moving in a straight line the whole time.
Also, don't forget to set the direction of the red ball when its internal flag 0 is on (I left that out in my file).


Yes the "Every 1 Second" simulates what the lag could be. I realize that it might bug if it crosses the line near the top or bottom, I just don't know what I could do... The main thing I'm trying to achieve is for the actual game (this was just for testing theories), because when the ball crosses the line, it sends its position, direction and speed to the other player. The other player's screen doesn't lag at all. It puts the ball on the line and sets its speed and direction and there's virtually no lag. But back to the player who sent the data, their ball didn't stop on the line, so by the time the other ball gets moving and blasting coordinates, it has to jump back to stay synced. So I'm trying to get the ball not to be set at the line, but estimate how far away it should be, then use your smooth movement example to smooth it out.
You didn't attach a file by the way
EDIT: Oh and they aren't always supposed to be in sync in that test example. It's just after the second that the red ball should be placed on the green one.




Sorry - Here's the file. Doh!
I have a think about the problem, but maybe you could consider other ways of sending and receiving the data? There are many ways to do an online pong game, but in the end it's really up to how "true" you want the data to be. It's up to you whether it matters if the ball is in the same place on both screens, or if you are only checking if the player managed to hit the ball back.


OHHHHHH
I think I have it figured out. It thinks the angle is 11.25 because the red ball bounced. But it's not!
I'll change that and see if there are still any bugs!
EDIT: I think it's working perfectly!!! THANK YOU SO MUCH ASSAULT ANDY!