Irrelon / ige

The Isogenic Game Engine
525 stars 140 forks source link

Streamed entities warp for no reasons #256

Closed Firnael closed 11 years ago

Firnael commented 11 years ago

Hi,

We managed to get our map and some streamed player walking on it. I don't know why, but everytime someone log in or out, all the streamed entities (for now, players) got warped to map origin (0, 0, 0).

Did you ever witness this issue ?

Irrelon commented 11 years ago

No, I suspect it is your game code. Take a look at the server code that handles client log in and see if you're code is calling translateTo() on anything.

On 5 April 2013 14:50, Firnael notifications@github.com wrote:

Hi,

We managed to get our map and some streamed player walking on it. I don't know why, but everytime someone log in or out, all the streamed entities (for now, players) got warped to map origin (0, 0, 0).

Did you ever witness this issue ?

— Reply to this email directly or view it on GitHubhttps://github.com/coolbloke1324/ige/issues/256 .

Firnael commented 11 years ago

There is nothing like that :( I got a .translateTo(0, 0, 0) in my _onPlayerEntity network event, but the players got warped when someone either connect to the game, or leave it. Looks like this happens when the player list (ige.server.players) is modified (player added or removed).

Irrelon commented 11 years ago

It's definitely in your game code somewhere, you'll need to step through the code and work out why. Try commenting out the translateTo() calls first.

On 5 April 2013 16:00, Firnael notifications@github.com wrote:

There is nothing like that :( I got a .translateTo(0, 0, 0) in my _onPlayerEntity network event, but the players got warped when someone either connect to the game, or leave it. Looks like this happens when the player list (ige.server.players) is modified (player added or removed).

— Reply to this email directly or view it on GitHubhttps://github.com/coolbloke1324/ige/issues/256#issuecomment-15960570 .

Firnael commented 11 years ago

Even when removing it, I got this warps. Can I log when any entity calls the translate() or translateTo() methods ?

Irrelon commented 11 years ago

You can extend your class with a translateTo() that overrides the original call and log it. At the bottom of the call don't forget to call the super-class translateTo() so that it still does something!

On 5 April 2013 16:55, Firnael notifications@github.com wrote:

Even when removing it, I got this warps. Can I log when any entity calls the translate() or translateTo() methods ?

— Reply to this email directly or view it on GitHubhttps://github.com/coolbloke1324/ige/issues/256#issuecomment-15964154 .

Firnael commented 11 years ago

Ok, I isolated the bug. It comes from the way we initialize our entity server-side :

onPlayerEntity: function (data, clientId) { if (!ige.server.players[clientId]) { ige.server.players[clientId] = new Character(clientId) .box2dBody({ type: 'dynamic', linearDamping: 0.0, angularDamping: 0.1, allowSleep: true, bullet: true, gravitic: true, fixedRotation: true, fixtures: [{ density: 1.0, friction: 0.5, restitution: 0.2, shape: { type: 'rectangle', data: { width: 10, height: 10 } } }] }) .id('player' + clientId) .isometric(true) .streamMode(1) .mount(ige.server.objectLayer); }

The box2Body part mess things up. Without it, nothing warps. But if you don't init it on server, how can you handles collisions server-side ?

Irrelon commented 11 years ago

Creating a box2d entity will not warp anything. Have you checked the networked physics example to see if you're doing similar stuff?

On 5 April 2013 17:28, Firnael notifications@github.com wrote:

Ok, I isolated the bug. It comes from the way we initialize our entity server-side :

if (!ige.server.players[clientId]) { ige.server.players[clientId] = new Character(clientId) .box2dBody({ type: 'dynamic', linearDamping: 0.0, angularDamping: 0.1, allowSleep: true, bullet: true, gravitic: true, fixedRotation: true, fixtures: [{ density: 1.0, friction: 0.5, restitution: 0.2, shape: { type: 'rectangle', data: { width: 10, height: 10 } } }] }) .id('player_' + clientId) .isometric(true) .streamMode(1) .mount(ige.server.objectLayer);

The box2Body part mess things up. Without it, nothing warps. But if you don't init it on server, how can you handles collisions server-side ?

— Reply to this email directly or view it on GitHubhttps://github.com/coolbloke1324/ige/issues/256#issuecomment-15966217 .

Firnael commented 11 years ago

Alright we'll check that ans get back tout you. Thanks a lot :)

Firnael commented 11 years ago

Still struggling with this issue :( We checked the network physic example but we didnt find the bug's cause. We tried to use your entities on our project, and when we call their .destroy() method, we got the warp bug on our player. The thing is, we don't really need advanced collisions, so I a way, we can get rid of Box2d. It's just annoying to get stuck !

Irrelon commented 11 years ago

So is the bug is reproducible on the example as well?

I'm writing a space game MMO called Starflight that uses box2d server-side and has players connecting and disconnecting at random but nothing warps anywhere. This would point to an issue with your game code over the engine but that doesn't mean there isn't an engine bug, it could be that the two use cases are quite different since you are in an isometric view and Starflight is flat 2d.

That said, from the engine's view, the underlying data is all in 2d and later converted to isometric projection at render time so I don't think that would make a difference.

If you run the network physics example, do you see the warping effect? That is creating and destroying entities all the time at high speed. If you don't see it on the example then it MUST be a game code issue.

The only other thing I can suggest is that you zip and send your project to me (rob@irrelon.com) and I can try to solve it but I am super busy so it may take a couple of days for me to get around to it!

Firnael commented 11 years ago

We'll check if we can reproduce the bug during the upcoming days, and get in touch. Thanks for your time :) !