www.neoaxisgroup.com Forum Index Portal
 Main  •   Wiki  •  FAQ  •  Search  •  Preferences  •  Register  •  Profile  •  Log in to check your private messages  •  Log in
Calendar 
View next topic
View previous topic

Post new topicReply to topic View previous topicList users that have viewed this topicSave this Topic as filePrintable versionLog in to check your private messagesView next topic
Author Message
SodanKerjuu
Commercial License
Commercial License



Joined: 16 Sep 2008
Posts: 730

blank.gif
PostPosted: Mon Oct 19, 2009 5:17 pm  Post subject:  PlayerCharacter precognition [Not needed] Reply with quoteBottom of PageBack to top

I really wish this would be done sooner than 1.0 because without it the engine is quite useless for any serious multiplayer gaming.

Controlling your character feels really clumsy with pings over 100.

I've tried to implement methods to move the character instantly on client, but without results.
It's mostly because you cannot control physical bodies properly client-side.

100-200 and you cannot do accurate movement.
200+ and you will have trouble navigating indoors.

I will do my own hacky way to make it feel smoother for clients, but I'd rather see proper implementation in the engine.

Btw, if you need simulate ping for testing, you can compile Lidgren network dll in debug mode and search the code for
SimulatedMinimumLatency




Last edited by SodanKerjuu on Thu Oct 22, 2009 8:44 am; edited 1 time in total
   OfflinePersonal Gallery of SodanKerjuuView user's profileSend private message
Maxwolf
Moderator
Moderator


Age: 25
Joined: 28 Nov 2007
Posts: 1128
Location: Vancouver, British Columbia
canada.gif
PostPosted: Tue Oct 20, 2009 12:31 am  Post subject:  (No subject) Reply with quoteBottom of PageBack to top

Taken from PhysicsSystem.config under physXSpecific a note that might shed some light into the lower workings of the engine at play here:

Quote:
Raycasts and Manual Movement Problems.

PhysX SDK keeps a double-buffer of all shape states and will not update
until a simulation step is taken. For example the result of setting the
global position/rotation is not immediatly visible until a Tick occurs.

Example: If physical body is moved (by code) you must update the
state of the physics simulation inside PhysX (swap buffers).
This is a CPU intensive operation! If double-buffer is not
updated then raycast will fail with calculation errors
(phantom object with old position/rotation).


Could it be possible if the server or client/server (meaning playing the game and hosting it) if using PhysX suffers from this double checking of old position.

Other things that I need to check about basic multiplayer functionality (since the hardest part was actually integrating it into the engine and entity system, there will be problems...)

1. Multiple clients connecting (10+) to sever at once can sometimes cause stack overflow or in some rare instances a lock up on a dedicated server a client hosting a game doesn't seem to get the hang up.

2. The high lag problem is noted, it feels like you are being held back by a rubber band or walking through clay when latency rises above 150+ milliseconds.

3. Multiple people clicking on "usable" objects at once can sometimes cause confusion on the server. Example: 10+ people all clicking use on a tank to enter it at the same time can cause interesting race conditions.

4. Bullets sometimes don't seem to hit where you fire them in high lag situations. I don't know of the checking of old position has something to do with this but it might.

Those are the things I have noticed in the base SDK, not counting my own issues integrating it with my code base for Incognito for things like inventory system. (I have issues with clients inventory getting wiped by server, so you enter tank, loose all your guns upon entering because the server creates a NEW you and properties are copied to it kind of like moving your "soul" around if I may be so frank Smile

_________________
I'm NOT paid or work for NeoAxis. I only help moderate these boards. My opinions are not the opinions of NeoAxis Group LTD.

Taurus Gender:Male Buffalo OfflinePersonal Gallery of MaxwolfView user's profileSend private messageSend e-mailVisit poster's websiteAIM AddressYahoo MessengerMSN MessengerICQ Number
SodanKerjuu
Commercial License
Commercial License



Joined: 16 Sep 2008
Posts: 730

blank.gif
PostPosted: Tue Oct 20, 2009 2:10 am  Post subject:  (No subject) Reply with quoteBottom of PageBack to top

I've worked around the bullet problem by using a custom method where client's view of the world is taken as legal and server only checks against static / collision objects from the client's claimed data.
An area is cast around the current client position to see if the client's claimed raycast could have occurred. This is a good method since the client can shoot what he sees, when he sees, and only cheat possible is shooting through other dynamic objects (if you don't take into account all the usual stuff like aimbot, wallhack and speedhack).

Number 3 is also noted. We managed to get two players inside one tank where other player could only fire the cannon, while the other could only move.
I'm planning on checking all the possibilities of having multiple player intellects using object during a single tick.
Pretty sure it can be negated by carefully checking all the functions and testing for dualities in each step.

It's hard to believe that the code is the problem for dedicated servers,
since all the tests against EntitySystemWorld.Instance.IsServer() will be true for client running a server and dedicated alike.
Only thing dedicated is missing are the rendered frames, but not many will require them.

One thing I noticed that if I want to do Client-Only physical objects I need to simulate the physical world. So in GameEngineApp.cs I added the following code into the OnRenderFrame() method:
Code:
            //SodanKerjuu: for clientside physics objects we need to simulate physicsworld
           
            if (EntitySystemWorld.Instance != null)
                if (EntitySystemWorld.Instance.IsClientOnly())
                    PhysicsWorld.Instance.Simulate(RendererWorld.Instance.FrameRenderTimeStep);


But what I meant that you cannot do anything to the physicsmodel of entities which have NetworkType.Synchronized, they just won't take any forces or alterations from the client.

Currently my method for precognitive movement is to create a camera vessel entity client side for his player character and move the vessel similar to how the player character would move.
The vessel cannot have physics or it will interfere with other objects (dunno why if it's client-side only), so it is not an exact replication of the player character physics, but it's close enough for me at the time being.


   OfflinePersonal Gallery of SodanKerjuuView user's profileSend private message
Wellu
Commercial License
Commercial License



Joined: 14 Nov 2007
Posts: 1547

finland.gif
PostPosted: Tue Oct 20, 2009 5:39 pm  Post subject:  (No subject) Reply with quoteBottom of PageBack to top

I don't know if C# has synchronized methods but it seems some problems could be tackled using them.

In Java a method can be declared synchronized meaning only one thread can be executing at once. This means all other attempts are locked out for the time being, but only one player could enter a tank etc.

_________________
http://games.kipase.com/

 Gender:Male  OfflinePersonal Gallery of WelluView user's profileSend private message
SodanKerjuu
Commercial License
Commercial License



Joined: 16 Sep 2008
Posts: 730

blank.gif
PostPosted: Thu Oct 22, 2009 8:37 am  Post subject:  (No subject) Reply with quoteBottom of PageBack to top

I might have overlooked the problem a bit.
After two days of trying different methods and thinking it thoroughly,
I've figured out how to do correct precognition.

Basically the thing was to make player characters non-synchronized and implementing a class to
control the data between the client instance and server instance.

The end result is clean, working and very flexible (you can create characters with or without synchronization).

To put it simple, here's my mind map:
Image

I already have it working and have implement the basic reflection methods.

And here's proof of concept:
Image

In the picture you see one character which is not reflected (only exists on the client) and one character which
is reflected but without correction, so the errors that occur over time (due to lost packets, etc) will not be fixed.
Feels grrrreat man!

Gonna look into the dead reckoning thingy once needed.

edit: updated the mindmap...


   OfflinePersonal Gallery of SodanKerjuuView user's profileSend private message
Goto10
Commercial License
Commercial License


Age: 32
Joined: 14 Sep 2008
Posts: 246

norway.gif
PostPosted: Thu Oct 22, 2009 2:32 pm  Post subject:  (No subject) Reply with quoteBottom of PageBack to top

Thanks for sharing your method. I know I'll need to look into this too.


Aquarius Gender:Male Horse OfflinePersonal Gallery of Goto10View user's profileSend private message
dazrulez
Commercial License
Commercial License



Joined: 18 Nov 2007
Posts: 216

uk.gif
PostPosted: Sat Mar 06, 2010 1:17 am  Post subject:  (No subject) Reply with quoteBottom of PageBack to top

it seems that this:

Code:

            if (EntitySystemWorld.Instance != null)
                if (EntitySystemWorld.Instance.IsClientOnly())
                    PhysicsWorld.Instance.Simulate(RendererWorld.Instance.FrameRenderTimeStep);


is all you need to do, after removing how the server sets the bodies positions then you are able to add forces to bodies also

also incase of lag and any hacks implimented, i send the server position to the client every 4 seconds during a movement

this worked perfectly for me! although, a reflector is a much cleaner way of doing it if you still require the synchronised dynamic entities in the old way

_________________
Image

 Gender:Male  OfflinePersonal Gallery of dazrulezView user's profileSend private messageVisit poster's websiteMSN Messenger
liiir1985
Commercial License
Commercial License



Joined: 15 Apr 2008
Posts: 209

china.gif
PostPosted: Sat Mar 06, 2010 1:39 am  Post subject:  (No subject) Reply with quoteBottom of PageBack to top

I don't know what kind of online game are you going to make.
As I can tell from my 2 years of MMORPG server development you don't need precognition at all.
It's normally like this:

Client performs movement and physic all by his own, it can even continue move if the connection is broken. it sends only the target coordinate the player is moving to.
And then the server checks if the movement is valid, if so, it broadcast the message to other player who can see, if not, roll back the movement and tell the player to knock back to original position.

for MMORPG, client only needs to send the move target coordinate packet 1 time per sec, for FPS maybe 5-10 times per sec.
Anyway, this model: Player want to move->client sends move request->server tells where to move->client perform move and does physic isn't good for internet, it'll make player feel very lag. So you need: Player want to move-> client does movement and physic(don't wait for server's reply)->send target position to server->server check, if valid broadcast message and don't need to tell the original player it succeed, if failed, knock back the player.


   OfflinePersonal Gallery of liiir1985View user's profileSend private message
dazrulez
Commercial License
Commercial License



Joined: 18 Nov 2007
Posts: 216

uk.gif
PostPosted: Sat Mar 06, 2010 2:46 am  Post subject:  (No subject) Reply with quoteBottom of PageBack to top

liiir1985 wrote:
So you need: Player want to move-> client does movement and physic(don't wait for server's reply)->send target position to server->server check, if valid broadcast message and don't need to tell the original player it succeed, if failed, knock back the player.


nice idea, thanks Very Happy

_________________
Image

 Gender:Male  OfflinePersonal Gallery of dazrulezView user's profileSend private messageVisit poster's websiteMSN Messenger
SodanKerjuu
Commercial License
Commercial License



Joined: 16 Sep 2008
Posts: 730

blank.gif
PostPosted: Sat Mar 06, 2010 3:26 pm  Post subject:  (No subject) Reply with quoteBottom of PageBack to top

I'm making RTSFPS game and rigorous updating of positions is necessary (information sent each tick).

The character reflector is far from perfect in the sense that it is very easy to cheat at the moment.
Basically each client sends his position each tick and server shares this information with face value.
This way each player will feel their movement to be very accurate without any delay.
But as each client even calculates gravity for himself, it would be really easy to just stab the memory and make yourself flying,
even instantly teleporting to other place.

I will worry about cheating later.

There are certain things I need to improve a lot.
The creation of the client side characters is a bit hacky, as well as certain default things doesn't work,
like NeoAxis FireInfluence can crash the server.

The picture I posted above is a bit outdated, I could share the whole class and give info how to set it up,
it's a good starting point for precognitive movement as the initial problems are solved in a smart way.


   OfflinePersonal Gallery of SodanKerjuuView user's profileSend private message
Hell Entertainment
Commercial License
Commercial License



Joined: 06 Jan 2009
Posts: 624
Location: Belgrade
serbia.gif
PostPosted: Sat Mar 06, 2010 4:12 pm  Post subject:  (No subject) Reply with quoteBottom of PageBack to top

Sharing would be nice Smile

_________________
Updated GridPathFindSystem
Smarter AI
Arilienta (Our NA Game)

   OfflinePersonal Gallery of Hell EntertainmentView user's profileSend private messageVisit poster's website
dazrulez
Commercial License
Commercial License



Joined: 18 Nov 2007
Posts: 216

uk.gif
PostPosted: Sat Mar 06, 2010 10:43 pm  Post subject:  (No subject) Reply with quoteBottom of PageBack to top

strange - the physics work perfectly for my player character that im controlling, and other playercharacters that have a user controlling them work perfectly, and i can view there movement with no issues. but when i try and use the same setup for gamecharacters (which ive also tried converting to playercharacters) and i add a force to the physics body, the body becomes detached from the mesh and acts crazy :S it makes no sense - the control is exactly the same for the play controlled one and the game ai.. i use a task move for both of them, and both recieve the values correctly, also the movement works on the server for everything perfectly, just not the client

_________________
Image

 Gender:Male  OfflinePersonal Gallery of dazrulezView user's profileSend private messageVisit poster's websiteMSN Messenger
Display posts from previous:      
Post new topicReply to topic View previous topicEmail to a Friend.List users that have viewed this topicSave this Topic as filePrintable versionLog in to check your private messagesView next topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All times are GMT
Powered by phpBB2 Plus