Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Multiplayer Theory Help

Author
Message
Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 1st Oct 2007 21:21 Edited at: 4th Oct 2007 22:23
--------------------------------------------
Attempting to better explain my situation
--------------------------------------------
How would i go about coding projectile weapons in a top-down shooter?

I am simulating the client 100ms behind the server time.

Therefore to perform a standard instant (raycast) shot, i send a 'bullet-fired' message to the server. The server receives this, works out when the delay on the message (100+Round-Packet-Trip Time). The server then looks back into saved history data to the correct time, locates the player positions at that time, and raycasts from the position the player was when the client fired the bullet to the position of the player (also when the client fired the bullet) being checked for collision (the player being shot at).

However, difficulties arise when i try to code projectiles.

I will list the options i have thought of here

Option A (Which i have implented at the moment):
The server recieves the fired bullet message and stores the delay in a variable.
This bullet is fired immeadiatly server side.
Everytime i check for collision, the players are moved back to their position at the "Current Time - Bullet Delay" and collision is checked for as normal.
This works fine, but there is currently no bullet simulation client side.
and i am not sure how to implement it effectivly.
To do this i think i would have to send a "bullet fired" message to each client, containing the bullet position and angle that will be present when the message is recieved by that particular client. I would also have to delay the message to arrive after 0.1s so as to get an accurate simulation.

However this would cause a delay on the client that fired the bullet of approx 0.1s as bullet simulation would not begin immeadiatly.

Option B:
Begin simulating the bullet after 0.1s (the view delay) client-side and fast-forwarding the bullet to its position when it is recieved by the server. This is then fast forwarded again to the time it will be at when recieved by other clients and sent to these clients. The problem with this, is that there will be a seemingly big jump when the other clients recived the bullet message. It will appear n units infront of where it started. Although this will have a 0.1s time period in which to work due to the view delay.

Option C:

Your idea here?

At the moment Option B is looking the best idea...

Let me know if you have an ideas!

Thanks


------------
Old Post
------------

Okay, i am creating a multiplayer shooter type game.

I have based my game so far on this article which is very helpful and informative. http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking

I have everything inside the article working, interpolation, prediction (needs improving), lag compensation and everything. The problem is i intend to use slowish projectile based weapons. These are not described in the article and i am stumped as to how i would implement them.

My client(s) are rendering the data 0.1s behind the server time so if i clicked to fire a shot, it would either have to be delayed, or be shown incorrectly on the client side.

I assume i would also have to log the positions of the projectiles as well as the players as i need to check if the projectiles collide with each other too.

Any ideas would be very welcome. This multiplayer stuff confuses me.

Thanks a lot, let me know if anything is unclear, i'm not good at explaining things
Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 2nd Oct 2007 00:31
I've had an idea to solve half the problem

When the server recieves the fire_bullet message, the bullet delay from real time is stored (Packet Round-Trip-Time + Client View Interpolation). Every time collision is checked for, the players are cast back to their position at [CurrentTime - BulletDelay] and a ray is cast from the old bullet position to the new bullet position.

This seems like it should work in theory?

Any ideas for the client-side prediction?
Roxas
18
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 2nd Oct 2007 19:11
Please i dont understand that code!

And i want smooth multiplayer movement can you give me your code translated from that theory?

Im really noob when it comes to multiplayer networking!

[center]
Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 2nd Oct 2007 22:16 Edited at: 2nd Oct 2007 22:16
Excuse me?

I'm going to ignore that comment.

Any ideas welcome
Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 3rd Oct 2007 23:12 Edited at: 3rd Oct 2007 23:15
Okay i implement the code as described in post #2 and it works well on colllision, but there is no client side prediction and i don't think it would be possible like that??. I guess when the server recieves it i should fast forward the bullet the distance it would have moved during message delay and them simulate as if it was single player from the client?

Edit: But this would cause a problem on sending the data to other clients, as if it is simulated in real time on the client side then by the message is relayed to other clients, their will have been delay, so the bullet would be behind where it should be or if repositioned, it would appear infront of the player.

Any ideas?

Thanks
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 4th Oct 2007 00:29
I think you're pretty much the expert on this at the moment, lol! I have no idea

Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 4th Oct 2007 19:18
That is definatly not true Thanks for the reply though! Is anyone knowledgeable about this kind of stuff?
Mr Bigger
19
Years of Service
User Offline
Joined: 31st Jan 2005
Location: was here!
Posted: 4th Oct 2007 20:22
Seems like you would need to run the same prediction code on the client as the the server is using so the client can predict the server.If the projectiles are very slow and can collide then they would need to be handled in a similar manner as the players.


AMD 2600+/1GB ram/GeForce 6600oc 256MB/W2KPro/DBPro 6.6.b
Xlaydos
20
Years of Service
User Offline
Joined: 26th Mar 2004
Location:
Posted: 4th Oct 2007 20:38
I am running the same prediction code client and server, but the problem occurs in the lag time.

For example:
T = Time at which client player hits fire
L = Round-Packet-Trip time from client to server

If the client started simulating from T, it would be ahead of the server as the server would be simulating the bullet being fired at T+L/2

I was thinking about the projectiles handling and i don't think i need to save the history of the projectiles if i go about coding it right. This is hard to explain but as the bullet collision detection is all server side, which will all be simulated at the "correct" time then bullet-bullet collision should not need any backwards tracking of positions and bullet-player collision could be done by backward tracking the players.

Login to post a reply

Server time is: 2024-05-02 21:18:30
Your offset time is: 2024-05-02 21:18:30