Network ownership is a dangerous place, but good luck. Take a look at what I achieved with my method:
External MediaThat looks smooth but the thing is will it still be smooth under heavier conditions is what really matters
That’s an old game that I made 4 years ago. I am currently working on a private newer game.
The newer game works by every .1 seconds sending a list of all the dodgeballs positions and velocities, and then the clients apply them. Physics handles the collisions for the ground and walls, and if it’s not perfect, It updates pretty smoothly the next 10th of a second.
@Btg3Hvyg5B9RTZbzEN4j
If you’re not using physics, I would recommend it, it’s not going to have too much of an impact on performance with 1 ball, and it wouldn’t really be noticeable if you update it fast enough.
Which heavier conditions? Faster speeds? Higher ping? You can’t really have true smoothness with high ping since the ball will have to eventually move to the real position, even if that is 50 studs away. I think this system currently is just missing the spin and I could improve on the ball stopping.
I don’t quite get what you mean by using physics for the collisions. Do you just have the clients spawn an actual ball part and detect .Touched events to tell the server it should bounce? But that would be very prone to cheating. Could you elaborate?
Edit: Did you mean you have a physical part on the server too? And then just sync the clients with that part every X seconds. That would make more sense to me
I have a similar issue, also what are you using for hitdetection?
I cast a ray in the direction of movement. It works well but starts to get icky when the ball enters a resting state.
can i see the movement code and the code where you make the raycast?
Yes, I have an invisible server ball, and that ball’s data is sent to the client every 10th of a second. Any changes made to the clients ball on the client won’t change anything, as the damage event, and all other events are on the server. The client’s ball is just so the player can smoothly see where the ball is, and where it is going.
This is what I did a couple months ago. And looks like I’ll have to do it again because collisions are a pain.
What do you use to move the server ball? LinearVelocity, tweening or lerping?
Could you help me out with it as I am struggling to make it work with collisions, my discord is x64x70
This version might be messy because I use a spherecast instead of a raycast.
function BallSimulation:Simulate(deltaTime: number)
if (self.Resting) then return end
self.LastPosition = self.Position
self.Velocity += Vector3.new(0, -9.8 * self.Mass, 0) * deltaTime
self.AngularVelocity = self.Velocity / self.Radius
local nextPosition = self.Position + self.Velocity * deltaTime
local spherecast = workspace:Spherecast(self.Position, self.Radius, self.Velocity.Unit)
local floorcast = workspace:Raycast(self.Position, Vector3.new(0, -1, 0) * self.Radius * 2)
local hit = false
if (spherecast) then
self.Position = spherecast.Position + (spherecast.Normal * self.Radius)
self.Velocity = (self.Velocity - 1.8 * self.Velocity:Dot(spherecast.Normal) * spherecast.Normal) * 0.8
hit = true
else
self.Position = nextPosition
end
if (floorcast and (self.LastPosition - self.Position).Magnitude < 0.1) then
self.Resting = true
end
return hit
end
I use the default Velocity property in the ball.
What is your issue? Why don’t collisions work for you?
The balls (client & server) have to be able to collide with the ground so CanCollide = true
It results in them colliding with each other
Also, how could I get it to bounce when using the ball’s physical velocity? .Touched event?
Yep, the touched event would work for bounces. Have 2 different collision groups, 1 for the client ball, and one for the server ball.
I see what you mean. My ball acts weird tho, it doesn’t seem to be affected by the velocity. I add it to the AssemblyLinearVelocity:
self.Instance.AssemblyLinearVelocity += Vector3.new(0, 9.8 * self.Instance.AssemblyMass, 0) * deltaTime * 0.8
Edit: it works great with LinearVelocity. Did you figure out how to make the ball stop smoothly?
I think the problem is with spherecasts, as if their hitdetection isn’t accurate enough?
Apparently if a spherecast is barely clipping with a wall it will ignore that wall… So you have to solve that somehow