Strange results locally vs. on an offsite server

Post your help queries and engine programming questions here

Strange results locally vs. on an offsite server

Postby cdiddy2 » Tue Dec 09, 2014 4:10 am

So I am getting some very strange results where when I run the game locally(done on various computers) I get different results than when I run the game on a rented server. So basically when the user presses up, the character is supposed to fly upward a little bit. But when I run it on the server the player flys way higher than they do when I run the server on my local machine.

Code: Select all
this._box2dBody.SetLinearVelocity(new IgePoint(0, 0, 0));
var movementVector = new ige.box2d.b2Vec2(0, -800);
this._box2dBody.ApplyImpulse(movementVector, this._box2dBody.GetWorldCenter());


That is the code used to launch the player upward. Seems pretty straight forward but on the server I have to change the movement vector to
Code: Select all
new ige.box2d.b2Vec2(0, -140);
To Get the same results that I get when I run it locally

Anyway really strange. Anyone know what could be up here?
cdiddy2
 
Posts: 27
Joined: Wed Dec 18, 2013 4:11 am

Re: Strange results locally vs. on an offsite server

Postby TheBenji » Tue Dec 09, 2014 12:16 pm

What do you mean by locally? Do you run the server on your local machine or do you mean local as in clientside?

Either way you probably need to take the time in account. I guess you put it into a Entity behaviour method that gets called every tick, right?
Depending on how fast the server is this might vary. Just multiply your number with deltaT and then it should work the same no matter how fast the server runs.
TheBenji
 
Posts: 7
Joined: Sat Nov 22, 2014 8:42 pm

Re: Strange results locally vs. on an offsite server

Postby cdiddy2 » Thu Dec 11, 2014 1:05 am

Sorry I meant running the server on my computer vs. running it on a rented virtual private server. Gets different results running on one or the other.

Ok I can try taking the tick delta into account. The weird thing is I am not taking the tick delta into account at other places where I do this exact same thing but there is no difference in other cases. I'll look for other differences too.
cdiddy2
 
Posts: 27
Joined: Wed Dec 18, 2013 4:11 am

Re: Strange results locally vs. on an offsite server

Postby cdiddy2 » Fri Dec 19, 2014 12:57 am

TheBenji wrote:Just multiply your number with deltaT and then it should work the same no matter how fast the server runs.


So like this? ige._tickDelta*-20. Thats the value to get it to run nice when I run the server on my local machine. But on the server this launches them way to high like what was happening before.
cdiddy2
 
Posts: 27
Joined: Wed Dec 18, 2013 4:11 am

Re: Strange results locally vs. on an offsite server

Postby rob » Tue Dec 23, 2014 1:02 am

When you press up on the keyboard are you sending a state to the server eg: player 1 up = true
Then when the user lets go of the up key are you sending the new state eg: player 1 up = false

?

If instead you are reacting to each key press instead of a state change that can cause the effect you are talking about...
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm

Re: Strange results locally vs. on an offsite server

Postby cdiddy2 » Wed Dec 24, 2014 4:56 am

rob wrote:When you press up on the keyboard are you sending a state to the server eg: player 1 up = true
Then when the user lets go of the up key are you sending the new state eg: player 1 up = false

?

If instead you are reacting to each key press instead of a state change that can cause the effect you are talking about...


I am using the same input as the multliplayer example 24.2
if (ige.input.actionState('left') || ige.input.actionState('a')) {
if (!this.controls.left) {
// Record the new state
this.controls.left = true;
// console.log(this._id);

// Tell the server about our control change
ige.network.send('playerControlLeftDown');
}


where the network command sets the state on the server.
cdiddy2
 
Posts: 27
Joined: Wed Dec 18, 2013 4:11 am

Re: Strange results locally vs. on an offsite server

Postby rob » Thu Dec 25, 2014 11:01 am

I think the first response was correct, you need to multiply your movement by the tick delta:

Code: Select all
new ige.box2d.b2Vec2(0 * ige._tickDelta, -140 * ige._tickDelta);


Tick delta is usually around 16 so whatever movement you wanted (e.g. 140) you should divide by 16 first when you hard-code it:

140 / 16 = 8.75 (call it 8 for easy calc)

So do:

Code: Select all
new ige.box2d.b2Vec2(0 * ige._tickDelta, -8 * ige._tickDelta);
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm

Re: Strange results locally vs. on an offsite server

Postby cdiddy2 » Sat Dec 27, 2014 3:55 am

So the tick delta when I run the server locally is around 30 and the Y number I use -800. The tick delta when I run the server on the virtual private server is around 17 and the Y number I use is around 140.

800/30=26.66
140/17=8.24

This means that I need to create a non linear function to get these numbers to work out. That seems way to hacky of a way to get this fixed.
cdiddy2
 
Posts: 27
Joined: Wed Dec 18, 2013 4:11 am

Re: Strange results locally vs. on an offsite server

Postby TheBenji » Sat Dec 27, 2014 10:08 am

No, just hardcode it with 8 and see if that works out for you on both.

Your computer execute the code on different speed, your server is just faster(/better) than your local PC thus the update method gets called more often.
The tickDelta basically just says how much time went by since the last time the update method got called.
So if you mulitply your number with tickDelta you always get the same number over a certain time frame, if that makes sense for you.
TheBenji
 
Posts: 7
Joined: Sat Nov 22, 2014 8:42 pm

Re: Strange results locally vs. on an offsite server

Postby cdiddy2 » Sat Dec 27, 2014 10:44 pm

Ah, that is very close. There is still slight difference between the two but not too much. There is a platform I test with to see if I can jump up onto it. I can easily make it on the external server but rarely make it when I run the server locally. Any idea why that slight difference would be there or why there is some variability in the jump heights, i.e. sometimes locally I can make it onto the platform but only rarely. Is that just because the tickDelta changes?
cdiddy2
 
Posts: 27
Joined: Wed Dec 18, 2013 4:11 am


Return to Help & Questions

Who is online

Users browsing this forum: No registered users and 1 guest
cron