as you can see in the video, the physics is different for some reason, even though they have the same properties??
i have no idea how i can make they behave exactly the same, please help
(half transparent ball is the actual ball, the fully visible is the client ball)
I don’t think you can make those 2 balls behave exactly the same, since they go through 2 seperate physics calculations. The server has a fixed physics frequency while the client’s physics depend on the device’s power
i am trying to have smooth physics for the client, setting network ownership only works for one player, but other people get the crappy laggy trajectory, this emulates where the ball would go, and goes about it smoothly for everyone. if only it was accurate
Here’s my idea from 1 minute of thinking, so it’s definitely not the best idea. We can still use your approach, but after each time the ball on the server touches something, clone that ball on the client with the linear and angular velocity of the ball on the server, and repeat. I still think this is a bad idea, but it’s best I can think of for now…
Keep in mind there will still be minor inaccuracies
that would make the ball very “laggy” every time it touches something since it teleports one in its place
i have tried constantly making the fake ball’s velocity match the real ball’s velocity, but the problem is, the fake ball can go offcourse like it did with this, and the matching would cause the fake ball to float midair for the real ball is on the ground
another solution i tried litterally teleport the fake ball to the real one, but since its copying the real ball, its laggy and no point in adding a fake ball at all if you’re just replicating the rela one
I meant turning off CanTouch of the client ball or set the its collision group to which that doesn’t collide with the server ball so the touch event wont fire like crazy
ok so i just tried it out, it was very “laggy”
my theory is the actual ball is already a bit different from the client ball, which makes the client ball teleport a noticible distance, which could be viewed as laggy
Looking at your game, it might be worth to implement your own physics with strict rules, independent on FPS.
It is not as scary as it sounds, however that will really depend on what you want to achieve.
For lossless 2D ball movement, that ignore other balls and only bounce of perfectly from static surfaces it is do-able. All you really need is to apply gravity force and calculate lossless bounces. Then you can have 100% predictable system.
On the other hand, if you want balls to bounce of each other and/or implement 3D physics, then that is A LOT of work and probably not worth it. Plus probably impossible, due to lag. For example if one player shoots their ball, at the same time as other player, it will be impossible to calculate them bouncing of of each other, if the server is not aware of their existence.
i would like to avoid doing anything custom as i have absolutly no experience in calculating physics.
maybe i can shift the client ball constantly to match the server?
Unfortunately the best way might be to write custom physics to simulate the ball, it might look hard first but it makes things easier on the long run. There will always be delay and some inacuracy(sorry for the bad grammar 'cause I am on mobile) between the server and the client so having custom physics that behaves the same on both is really usefull and more customizeable.