2 registered members (AndrewAMD, juanex),
1,247
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: [Anet] physics movement setup
[Re: darkinferno]
#285347
08/18/09 08:27
08/18/09 08:27
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
Serious User
|
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
it seems so far that almost all multiplayer demos i've seen so far with Anet use client side movement Yes, I already told you that I always do it clientside ^^ Why don't you also make it clientside? It's easier to program and isn't that laggy.
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: [Anet] physics movement setup
[Re: Dark_samurai]
#285351
08/18/09 08:34
08/18/09 08:34
|
Joined: Jul 2007
Posts: 959 nl
flits
User
|
User
Joined: Jul 2007
Posts: 959
nl
|
i am using the free anet together white newton and do it al server side
the project isnt that big but until now it works almost perfect
"empty"
|
|
|
Re: [Anet] physics movement setup
[Re: flits]
#285360
08/18/09 09:16
08/18/09 09:16
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
Serious User
|
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
Can you explain us in a few words how you are doing that? I think this is interesting for alot people (not only us).
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: [Anet] physics movement setup
[Re: Dark_samurai]
#285374
08/18/09 10:30
08/18/09 10:30
|
Joined: Jul 2007
Posts: 959 nl
flits
User
|
User
Joined: Jul 2007
Posts: 959
nl
|
i wil try to explain it as easy as i can but i am not realy a pro in multieplayer
first i create a server + client (whiteout the client it doesnt seem to being able to control the entities)
then startup the client
then when finshed al the loading stuff, send a var id of the client to the server(this maby needs to send some time after each other until it get reset by the server)
after that the server checks the id and creates a model and send only to that client the var back white NULL(stops looping the client voor sending the request)
the model wil need to know wich client has created him so take there the skill and give him that idd and update his skill
now you will need some controlling of the entitie by just adding him to the physics enigne
then you will need to be able to control its thie a device but that wont be that hard because your anet runs the function on each model
just wait until the model skill id isnt 0 anymore and then check if its the client idd else dont be able to control it
i hope you get the idee it wont be the best solution but it works almost every time
"empty"
|
|
|
Re: [Anet] physics movement setup
[Re: darkinferno]
#285387
08/18/09 11:01
08/18/09 11:01
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
Serious User
|
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
@flits: This could be done much easier. After you connected the clients with the host and did the loading stuff, every client creates his player using enet_ent_create(). With enet_ent_creator() you can check which client created the entity. So their is no need to store a id in the skill. In the function you can do the following:
if(enet_get_clientid() == enet_ent_creator(enet_ent_globpointer(my))) { /*you are allowed to control the player*/}
If you do the movement serverside, how do you transfer the control input from the client to the server? And how do you update the positions on the server?
@darkinferno: To start simple try it this way: Store the control inputs in ONE!!! skill. Use one bit for every key. send the skill if it has changed the server makes the according movement and updates the positions and angels using enet_send_pos/ang().
After that is working you will have to solve 2 problems: 1) If you have a high ping, you will notice that the controls of your own player will get slow. 2) Updating the positions and angles the whole time will cause a lot of traffic. You will have to implement death reckoning or something to reduce the traffic.
Best would be to do a mix of clientside and serverside movement. So that the thing you will see clientside is something like a preview of what will happen. But the real collision detection and movement will be done by the server.
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: [Anet] physics movement setup
[Re: Dark_samurai]
#285414
08/18/09 12:52
08/18/09 12:52
|
Joined: Oct 2005
Posts: 4,771 Bay City, MI
lostclimate
Expert
|
Expert
Joined: Oct 2005
Posts: 4,771
Bay City, MI
|
I do everything server side. That fixes things like speed hackers, item hacking etc. My process is like this - create an array of connections that contain things like a pointer to an entity, the particular connection id to the client that it refers to, etc..
- when a client connects i choose an empty array slot, fill it with there information (which i get from a local database that contains player information, such as name, type, health, mp etc.)
- I then send the info to all clients including the one just created, so that they can update there connection arrays. I also send all previous connected clients information to the new one so it stays up to date.
- the server than goes through a loop with a variable that repeatedly counts to a specific number than goes back to zero. every time it hits different numbers it does different updates, so lets say it goes to 10, it will go from 0 to 10 thne restart, at 5 it will request key presses, at 10 it will update all connections positions etc. All of the while the server is doing the moving and interacting of all the objects.
- create an array of connections that contain things like a pointer to an entity, the particular connection id to the client that it refers to, etc..
- when a client disconnects, the server sends a message to every client that the client with that id has disconnected, and the clients and the server itself all remove that players connection list entry.
- on a side note while all this is going on the client is also looping through the connections and moving entities to the estimated positions that they should be, this helps eliminate some of the choppyness, and i know samauri and flit know this but inferno, thats called dead-reckoning. If you want to get some decent theory, locoweed a long time ago made a tutorial about mp games with a6.22 its on the aum resource site. It is usesless code wise, but may give you a lot of idead mp theory wise.
That about sums it up. its not too complicated. I do some dead reckoning, and it is not a great idea to have the 1 in 10 frame updates for twitch games, but Im making an orpg and it works fine for that.
Last edited by lostclimate; 08/18/09 13:05.
|
|
|
|