3d transform data thru socket

Note, if its getting harder to conceptualize - then we can go full3D. We’ll move more data, but for our purposes that’s not really the point.

ok, I have the server and client running. I have fired up 2 clients at once and can see the “other” moving around. Using x and z I am able to see full 2D movement…turns, moving straight, etc. Not rotating yet, work on that today.

So far though, I am happy with what I see.

M

Good :slight_smile: Lemme know when you have some more questions.

ok, got player rotation working…in a round about way.

I found if I get the Matrix of the current transfrom on the client and get the heading(found math on net) and send that as the rotation as a double then apply it as a rotY(heading) when the other clients recieve it…


Transform3D toSend = new Transform3D();      
Matrix3d m = new Matrix3d();
toSend.get(m);

double heading =  Math.asin(-m.m02)


it seems to work… not sure if its correct, but the clients look ok.

more later…

ooops nevermind…lol

this works as long as you are facing forward. WHn you turn past your perpidiclar plane, you shoot behind yourself

Angle issue resolved(hopefully).

On to ‘Projectile hits player’ scenarios…

Obviously the server should deicide when someone is “hit” to limit hacker intervention. The server, in it’s current form knows the following about the player:
x, y, z, rotation in raw data.

about the projectile:
x,y,z, rotation in thr form of a Transform3D. This transform is updated per server click for the life of the projectile.

Should I create transform groups for both Player and Proj and do statndard collision detection with a behavior on the server, or is there a simpler ‘intersects’ method I am not aware of , or a better solution…?

Well you’re headed in the right direction with having the server solve the interaction. Here is where things start to get tricky. Each player has their copy of the ‘world’ and the server has its copy of the ‘world’ - which overrides theirs.

So lets start with a little bit of theory. If all traffic is flowing through the server, then the player is updating his position based off what the server says his position,stats, etc is - not what he thinks it is.

So lets look at what this means:

  • every frame I’m sending my information to the server
  • every frame (in the best possible case) the server will tell me where I am and I will move there.
  • every frame I will tell the server about projectiles I have fired
  • every frame the server will tell me about where all of the projectiles are in the world

So as you can see, this is where the server stops being a traffic cop, and starts being the world moderator. This is also where we have our first code change (remember we’re doing this in stages - I want you to understand why we’re doing things). The player is now only responsible for sending his positional information every frame (not the state of the world). The player is also responsible for telling the server when he wants to make a change to the world.

This solves two problems. First, it gives the server to mediate disagreements between the clients - because the only real world view is the servers world view “say whatever you want, but my judgement is law”. Second it makes it a lot harder to cheat (not impossible) because the server is the one making all the decisions.

There are some downsides to this, but we will come to those soon enough :slight_smile:

So, the player doesn’t change from the perspective of what it receives (its still going to receive a world state packet telling it where everything is and its facing, etc). But now it further limits what it sends every frame as every thing that the player wants to do is now a transaction to the server. “hey server I am moving to position blah.blah”. The player can then in its client move to that position with the expectation that the servers response will not be a veto of that move - so long as to the world that move is in truth valid.

So here we go:

A: move 1,1,90deg
B: move 2,1,20deg
server: (a:1,1,90;b:2,1,20) -> clients A,B
A: move 2,10,90deg
B: move 2,5,30deg + projectile 2,6,12deg
server: (a:2,10,90;b:2,5,30;p1:2,6,12)

Does that make sense so far?

Now here is where we get to the crux of online gaming (and one we won’t solve for some time yet) - latency. In our game it is likely that over a LAN the response from the server will happen fast enough that the clients and server can move in lock step fashion … but over the internet… hell would freeze over first.

But lets go ahead and implement this client server movement/shooting strategy and then proceed from there.

just a short clarification. The client is handling his own move with a behavior(wakeUpOnFrame(0) then does transform to transformgroup, then sends results to server) and sending that move to the server, who sends everyone moves out. Should I also be handling the clients move by what the server sends back(this is prior to the code change you are talking about at the end of your post)?

Sorry to take so long to respond. News world has been very busy of late.

Yes, the client would handle its own moves and the server would in the average case simply be validating that move. What happens in high latency environments what you will see is that you will do a lot of moving and then the server will pop you back to the last location that it computed for you. The worse the latency, the worse the popping. This is a factor in all online games (especially MMORPGs where the server has a lot of work to do).

ok, Ill switch my code back so my movement behavior is setting my local move for the players transform group and send that location to the server. Since I am using wakeup on frame(0) and the server is sending updates every 30 ms to all players, should I put a 30ms delay in the framerate? So they are attempting to be on the same page?

quick question…

I have set BoundingBox’s on all GameObjects on the server. I am setting there transform with the transform of the players and projectiles movements. But the BoundingBoxes never move. They are allwasy sitting at 0,0,0. Thus when I check for intersects of the bounding boxs it is alway strue for all objects, since the BoundingBox is sitting in the center for all objects.

Any thoughts?

M

[quote]ok, Ill switch my code back so my movement behavior is setting my local move for the players transform group and send that location to the server. Since I am using wakeup on frame(0) and the server is sending updates every 30 ms to all players, should I put a 30ms delay in the framerate? So they are attempting to be on the same page?
[/quote]
You’re catching on quickly :slight_smile: Yes, this magic number is something you want to adjust a bit depending on your dead reckoning strategy (how long do you want the player to be able to update their local world state before getting some sort of confirmation from the server about the state of other objects in the world).

[quote]quick question…

I have set BoundingBox’s on all GameObjects on the server. I am setting there transform with the transform of the players and projectiles movements. But the BoundingBoxes never move. They are allwasy sitting at 0,0,0. Thus when I check for intersects of the bounding boxs it is alway strue for all objects, since the BoundingBox is sitting in the center for all objects.

Any thoughts?

M
[/quote]
Unfortunately I don’t have a solution for ya. You’re doing the right thing. Basically you’re building a model of the game on the server and accepting as input the feed from other players and then sending out the world state based on what the servers model looks like.

Not sure however why the bounding primitives aren’t moving. This is going to likely be a Java3D thing. Do a quick log of what you’re receiving and what you’re updating the objects to on the server and see what is resetting the transformation matrix for them and making them stay at the world origin. Sounds like a bug in the world updating code.

But I can say that you are doing exactly what you’re supposed to be doing.

I have solved the bounds collision detection and it is working so far. Need to test with muliple users on diff systems. RIgh tnow I run the server and 2 clients on one box and I get some processor slow down.

M

Send me an AIM one evening (I’m on Eastern time, try me after 8PM EST) and I’d be happy to help ya out.

Strange question…

On my pc at the office and one of mine at home, with low end graphics cards, the game runs well. On my “good” system at home with a GeForce II card, my game just is dismal in speed.

Any thoughts?

M

That I couldn’t answer for ya without a clear understanding of how Java3D is using your machine.

Howdy!!

Been away from my little project a while, had to rewrite a VB desktop application at work and chose to use JAVA Swing. Going great.

Anyway, have the server side collision detection going well. When projectile hits a player, it logs the hit and removes itself from all players universes.

As soon as I can figure out what is wrong with my particualr machine I will get you a copy to test some.

Thanks

No problem. Post it here in the forums as others will likely choose to participate as well.

ok, I have done some more work, not much. But have hit a wall.
I was going to set up a test environment, but have found that if there are
two players on and one leaves the others system becomes horribly slow and bogged
down.

fiddlesticks!!!

M
:-/