Why do game variables change if I'm playing somewhere else.

0 favourites
  • 13 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hey I just finished making my 3d game and it seemed perfect at the start when I was the only play testers. Now I asked some of my friends to see if they would test it and they were up for it. This is when I saw the problem. In my game there is a jump strength variable which just makes it how high you jump, its a 3d game first person. In my computer when I play my game to test it, I try to jump to see if I don't just glitch through the roof which I don't but then when my friends (several people) tried out my game, when they jumped it seemed like the variable just doubled because they where jumping way to high and glitching over the ceiling. This isn't just for jumping cus when I walk in the game when playing in my computer I walk at a normal speed (variable=6) but when my friends walk they seem to walk at double the rate. I also tried remote preview and the same is happening just not to me. I don't know if this has to do with the household because I tried my game out it other computers of my household and those computers didn't have the glitch where you jump too high. I don't know why the glitch is everywhere but my own house (or internet). Why might this be happening and how do I fix this?

    Tagged:

  • Are you taking into account Delta-Time for your movements / jumps? If you're not, there's going to be a big difference between computers / monitors.

    Here's a post from Ashley about it construct.net/en/tutorials/delta-time-framerate-2

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • yes i am using delta time

  • Where are you playing the game from and how are you sharing it?

  • Weird. Are you *not* using it with Behaviors? Because Behaviors already factor it in, so you'd be undoing Delta-Time by using it on Behaviors.

    That's really the only thing I could think of. Hope someone else can help.

  • every tick my gravity is getting subtracted by variable GRAVITY divided by dt, i dont know if this helps

  • Where are you playing the game from and how are you sharing it?

    Computer and remote preview or google drive download link

  • Typically motion is done utilizing dt so it runs the same speed regardless of the framerate.

    So say you pc's screen updates at 60hz, you could make an object go 100 pixels in a second with:

    set x to self.x+100*1/60

    but if someone has a screen that runs at 120hz the object will move twice as fast with that.

    It is corrected by utilizing dt. This will move the object 100 pixels in one second no matter the framerate:

    set x to self.x+100*dt

    Now, all the motion behaviors utilize dt for you so everything should run the same speed regardless. Although there is no built in z axis motion behaviors so you'd have to look into how you're doing that and see if dt is utilized.

    As a side note, parabolic motion (like a jump or an object being thrown and falling with gravity) could be done with:

    var gravity=500

    add gravity*dt to velocityZ

    set z to self.z + self.velocityZ*dt

    However, that's just an approximation and can cause the utimate jump height to vary a bit at different refresh rates. It can be made more accurate like this.

    set z to self.z + self.velocityZ*dt + 0.5*gravity*dt*dt

    add gravity*dt to velocityZ

    Construct 3 already does that with the platform and bullet behaviors with it's gravity, but it may be useful if making the motion with events.

  • ok thanks for the help guys

  • Well what I'm thinking is if you are on a remote preview and they are testing an exported game then the variables could be different. You can be playing two different versions of the game and in the preview you could be starting from a different point of the game.

  • i have one question, so i figured out how to fix this i just replaced all the events from delta time to a specific number (millisecond) but this is overly complicated. I figured that the reason the glitch was happening is cus my friends have 240 hz monitor and i have 60 hz which makes the delta time faster which makes it so you jump higher. is there a way to cap my game at 60 hz no matter what your monitor is

  • Sorry didn’t see the other posts above my reply. Dividing by dt doesn’t sound like a great idea. Should be multiplied. Dividing by dt would make it faster at higher refresh rates.

    100*dt would be 100/60 at 60hz and 100/240 at 240hz. Which is correct.

    When you divide

    100/dt would be 6000 at 60hz and 240000 at 240hz. Which doesn’t seem right.

    Also your last post seems to be going opposite to the suggestions by going from using dt to a fixed step.

    Anyways, as to your other question, no, there isn’t a way to make the game use a fixed refresh rate. There have been attempts at ways to do it but it’s overly complicated and doesn’t really work with behaviors and such.

  • Ok thank you very much guys this really helped out a ton

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)