Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
1 registered members (Grant), 999 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
a basic question #302799
12/22/09 10:16
12/22/09 10:16
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline OP
Senior Expert
ello  Offline OP
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
hi there,

how would i setup a game where two players kick a ball between each others.. i had a look at the pong example, but since i never did multiplayer before i have no clue how the players and the level (a scripted one) are to be created . i only think that the ball and the player position need to be send somehow, but thats all laugh

a little bit input would be cool..

cheers,
ello

Re: a basic question [Re: ello] #302821
12/22/09 15:20
12/22/09 15:20
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
Will you be using game studio native or a 3rd-party-plugin?

You have to decide if you'll be using
a)server-side movement (less cheating, but you may create a little more traffic as user input needs to be sent to the server instead of just movement, and you may need to think of a way to decrease the lag that the player himself sees, especially in first person mode. If a player presses a key, that command will get send to the server, who will see if and how far the client can move and then move the client and send back to the player; you'll have lag.)
b)client-side movement. I recommend this one, cause I think it's simpler to code, and if you're not making a game that needs to be 100% hack-safe, use this.

At this point I wrote two or three paragraphs what I would do next, only to notice that native 3dgs works entirely different from ANet, which I've been using, so I deleted them again. I recommend using ANet, it's fast and stable, and has great support. I think you should try getting a Demo from it to work.

As a starting point:
I usually use ANet to create the entities (enet_ent_create). Then I save the positions into their own skills, on the clients who created the player. Then I send these skills (not the .x, .y and .z values) to the other clients, because if you send x,y and z directly, then it'll be set to that place instantly, resulting in very "jagged" movement. Instead, send the skills, and on all other clients then move the players to that position if their skills change, smoothly.
If you then save the previous values of the skills you can use them to try and predict where the player'll go next (as a simple example: if vec_diff() of the two gives you the vector 0,1,0 then it'll be likely that, if you've updated 4 times a second, the player will keep moving at a speed of 4 quants per second (or one quant per quater-second) into the positive y direction). If you receive the next update and notice the prediction was false then you can interpolate and "smooth" it out by moving back towards the position it actually should have moved to.

I did make a demo that demonstrates movement, movement interpolation, movement prediction a while back, but it all uses ANet.
It also has the whole connection-process in it (or a simple example of how it can be done) and the entity setup. But if you want 3dgs native, you'll need to start elsewhere. (ent_create in native liteC seems to only run the function on the server. So I'd use ent_createlocal and then send the skills over an array.)

Sorry if all that confuses you, but I just noticed that 3dgs mp is so different from ANet frown. Hope it helps anyways...


~"I never let school interfere with my education"~
-Mark Twain
Re: a basic question [Re: Germanunkol] #302823
12/22/09 15:47
12/22/09 15:47
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline OP
Senior Expert
ello  Offline OP
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
thank you.. anet is no option since i have no money to spent.. i'll see if i can manage anything

Re: a basic question [Re: ello] #302829
12/22/09 16:00
12/22/09 16:00
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
Ok, then I think I can't give any specific ideas of how to code the movement. It's been too long since I've worked with 3dgs' MP.
Hope someone else can walk you through if you need it...
Good luck, and I hope to see the outcome laugh

Last edited by Germanunkol; 12/22/09 16:00.

~"I never let school interfere with my education"~
-Mark Twain
Re: a basic question [Re: Germanunkol] #302852
12/22/09 19:17
12/22/09 19:17
Joined: Nov 2002
Posts: 913
Berlin, Germany
S
SchokoKeks Offline
User
SchokoKeks  Offline
User
S

Joined: Nov 2002
Posts: 913
Berlin, Germany
I've done the game "Survive!" in A7.7 native multiplayer, and I switched to anet afterwards, because it's functions are far more convenient. Still I wouldn't say that the native multiplayer is worse than anet in every aspect. Okay, where to start?

1. Connection
With Commercial-Edition you need to pass -cl, -sv and/or -ip command line parameters to the engine to start connection. You need to use an external starter like I did, but it can also be made with 3dgs.
With pro edition you can use session_connect, which allows to show options, php based server lists and other stuff before starting to connect to a server.

just a hint: its easier to program all the network related stuff if you use a "dedicated server", which means that you start the server only with "-sv" command line, not with "-sv -cl". you can still start another instance of your game when you want to play on the machine that hosts the dedicated server.


3. entitys
The most important part of 3dgs multiplayer is to know WHERE your function is running. that is where most people fail. always keep that in mind!
use ent_create to create networked entitys. the function of the entity is always only run on the server, no matter where you use ent_create. thats very important and therefore your entity function needs to be completely different from what you are used to from singleplayer games. never check for any keypresses in the entity function!
If you want to access the entity on the client you have created it, use it's pointer. example for A7.70 upwards:
Code:
...
player = ent_create("pl.mdl", nullvector, pl_sv);
while (player.client_id == 0) {wait(1);}
//now you can access player and send input etc..


Another way to do this is using proc_client(..), check the manual on that. I've never used it.

You often want to have an entity function running on all clients, that does animations, lag-free movement etc. Use proc_local(...) once on the server (usually in the entity function) to set such a function. its automatically started for all connected clients and will also be started for future clients when they connect.
Skills can be send with send_skill(..). Thats often use to send input from the clients to the server. if you want the server to send something to all connected clients, use the SEND_ALL flag.

2. sending of simple data
use the send_string and send_var functions. read the manual, they are different from send_skill.

3. events.
the on_client and on_server events are really usefull, check them in the manual.

4. testing
you can run multiple instances of 3dgs on your local machine. simply start a server first, and then you can run several clients in window mode. the -ip parameter don't has to be set, the clients will automatically find the server. you can use the -pl parameter to set a client/player name.


5. scripted level:
load the level from the function main on all machines, server and clients. make sure you only use ent_createlocal function for creating the level during runtime! Everything else would be a waste of bandwith and you'd create several entitys on the same position, as every clients entity would be transferred to all other clients.
if parts of the level change and move, you should load the level on the server only with ent_create, it gets synchronised automatically then with all connecting clients.


EDIT: forget to mention that the position of networked entitys is automatically transferred. for your game idea, you'd create the player entitys and then change their positions on the server (c_move as usual) with input thats send from the clients. the clients then automatically see everything move, but it'll be a bit laggy. look up dplay_smooth, dplay_entrate and ent_sendnow if you want to try to fix that or create your own movement prediction system and set dplay_smooth to 0.

Hope that helped you, feel free to ask anything.
-SchokoKeks

Last edited by SchokoKeks; 12/22/09 19:25.
Re: a basic question [Re: SchokoKeks] #302853
12/22/09 19:37
12/22/09 19:37
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline OP
Senior Expert
ello  Offline OP
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
hey, thank you very much.. this should get me started...
i'll keep on asking if i need further assistance...

thanks again laugh


Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1