Im just programming a little client / server game.
I have two types of characters: My main player and monsters I can attack. When I attack a monster, it should run after my main char and the position of my monster should get updated.
My problem is: How should the new position of my monster get updated? If I send the new position of my monster after it hast moved, all the time, my Game will get VERY slow.
How should I send the position, when my monster moves?
Do you understand what I mean? Please write if you dont.
I’m setting something up like this right now. Actully, you don’t need to update every new pos from server; for example, make sure you’re using a UDP connection and then just send the monsters’ new poisition every .5-.05 a sec to synchronize with the client’s monster that is all ready moving towards the client/user.
Now attacks you’ll have to set up a little different, but perty much the same thing. Server will send a attact command ahead of time that will say (show animation attack at XX time). This way you can deal with some lag issues between you and client.
Aka, You attack Said Monster, Client Monster goes aheads and move towards client, (ms sec later) Server monster gets told it got hit and that it’s moving towards client, server updates its monster to match or just get close to clients monster, if client monster is moving too fast-tell client monster to move back some, Server tells client’s monster to go ahead and hit client when it gets there. Player hits monster in mean time, Server updates HP points, but “sees” that the monster will be attacking in another sec and tells client monster to show another attack animation at xx time, when XX time is reach on server and client, reupdate HP. so on till it dieas~
Thank you very much.
I have a function that returns the positions of all monsters on the map. Should I just send monsterxx moved to x,y or should I send monsterxx@1,2 monsteryy@3,4 =>
Should I send that one monster has moved or the position of all monsters?
Send the ones that are near playerxx. For example, if monster 1-6 is withen 20 meters of playerxx, tells playerxx all 6. Else, send 2. Don’t ever or try not to ever have to update every singal thing with its own call to user. (look up ping to see why)