question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Very Inconsistent function between computers.

See original GitHub issue

I’ve been working quite heavily on the “Physics” for our game and we’re quite happy with the movement system that we’ve created so far thanks to all of the information available online.

We have tested this on 7 computers and only 1 has had the issue.

Here’s a few parameters that I can guarantee:

  1. All Computers are using intel processors
  2. All Computers are using NVidia GPUs
  3. All Browsers are up to date
  4. Problem is PC specific, not browser specific from what I can tell. (Chrome, Edge, Opera, Firefox, issue exists on all or none)
  5. All tests are run from the piqnt space using the planck.testbed
  6. All PCs are running windows 10.

Here’s the code that’s causing the problem (note: we stripped everything away until this was the last thing) in testbed.step: Code also found in iForce2D (Moving at a constant Speed) We’re using forces for everything where possible not manually setting the velocity at all. All objects have a friction of 0.

let drag = jumpChangedDirections ? movementDrag : 0;
let desiredVelocity = (movementSpeed - drag) * movementDirection;
let change = desiredVelocity - currentVelocity.x; 
let force = mass * change / (1 / 60);   // 60hz
let walkingForce = Vec2(force, 0); 
player.applyForceToCenter(walkingForce); 

The mass and currentVelocity are just body#getter shorthand variables for readability.

On most machines, everything runs perfectly and we good a smooth movement experience that looks something like this: Example

However, on the PCs that have this problem, whenever the user attempts to move (which calls the code above in testbed.step they start to completely freak out. Example

We did some debugging remotely and I found that the cause of this issue seems to be over-compensation. Usually the value of change is only adjusted when you are starting and stopping. However, in this example, change gets set showing that the current x velocity is 1.8... so it compensates for that with some force. (Our gravity is really heavy, by the way)

But then it seems to permenantly compensate back and forth and never find the sweet spot again of moving at movementSpeed or standing still.

Example

I’m really not sure what would cause this to happen, as most computers seem to have no problems running this simulation. I’ve done everything I can think of, but it’s a huge concern for my game.

Note: A force is usually only applied once during our movement, unless the direction is changed or the player stops moving. This force value is calculated to be 420 or -420 depending on direction, and 840/-840 when switching directions. For some reason, on this one computer, it’s being adjusted constantly. There’s no friction, just to double-clarify.

Note 2: Also a strange thing to notice, but the problem starts at a velocity of 1.8, but… in our application velocity is almost always 7, 0 or -7 (movementSpeed) or 3, 0, or -3 (movementSpeed - jumpDrag)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
shakibacommented, Jan 29, 2021

Yeah, that makes sense, that’s why I suspected step is the issue–currently step is called on each frame (rather than each physics step), while physic is called each 1/60 seconds, so with 180hz frame rate step is called 3 times more than it should. I will fix this issue.

I changed script limit to 1M (it was 10K before).

1reaction
ChristianTuckercommented, Jan 28, 2021

@shakiba I’m going to be away for a few days, but I will send it off to be tested when I’m back.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inconsistent computer visibility across wired network
Im able to ping all computers on the network from all terminals succesfully. I have set the two function services to automatic in...
Read more >
Inconsistent behavior between computers in VBA
I have a piece of code that allows the user to input a custom value to be entered into the database. I also...
Read more >
Inconsistent answers from different computers using eig ...
I've been having issues lately with an inconsistency in answers from matlab across two different computers. I have two sparse, double complex matrices ......
Read more >
Why is my computer performance so inconsistent? - Quora
Computer performance is very consistent: the computer will always run as fast as it possibly can, within the constraints of the hardware and...
Read more >
Inconsistent results on different computers · Issue #166 - GitHub
Also, the trained estimator can be consistent between two different computers, but this is not guaranteed. So far I have been unable to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found