Ruskul's Forum Posts

  • Ashley

    On all my devices, regardless of browser, it appears that the difference between the hardware cursor and mouse.x/y remains consistent while switching between v-sync and unlimmited full frames.

    Do you know if that has to do with a polling rate on the browser side? It seems that whether fps is 60 or 35000, the lag time is still the same?

    EDIT / Update

    TIL Chrome collapses mouse events to match screen refresh rate. So regardless of how many frames you CAN run the game at, the input from the mouse at least, remains at 60 hz.

    https://developer.chrome.com/blog/aligning-input-events

    As far as I can tell, it looks like you can pull expanded info from the mouse event, but I don't see a way to increase the frequency (say 2x framerate)

  • On my fx504 with a 60hz screen:

    Firefox definitely does something that bumps the lag up to 4 frames.

    On chrome and Edge, I only see 2.

  • I've got 3 macbook airs, and one macbookpro, all at 60hz. I have an asusfx504 at 60hz, an Asusg15 at 144hz, an hp revolve at 40hz, and an assortment of all in one desktops to try some tests on (along with like 100 other computers)

    I am not getting the same answers, depending on the device used and browser. Assuming one wants to export the game as a standalone app for windows, I should test using Edge right?

    Eitherway, I know chrome has some built in latency but didn't have a clue about the others. What is weird to me though, is how much the future prediction jitters in some cases. I thought it could be related to dt fluctiaitons, but that doesn't seem to fully account for it.

    I am going to try to create a setup with a qmk keyboard controlling the mouse so I can get absolutely precise mouse input - though I'll have to account for the lag introduced by the board if that is relevant.

  • Hey, here is the file: https://drive.google.com/file/d/1yQ01n8EX2RFXmgUoQSiuPWFGU4UcmxMZ/view?usp=drive_link

    I misspoke earlier, frame lag is 4, not 2. 2 is reasonable, 4 is a much harder pill to swallow, especially when it is always 4/60ths of a second regardless of actual frame rate.

  • Further exploration leads me to believe (on the current computer at work) that:

    A) Input lag is 2 frames at 60hz. I conclude this by storing the previous mouse coordinates one frame back and extrapolating forward 2x that distance. That position is typically spot on the hardware cursor

    b) Changing to unlimited fps, either ticks only or full frames, still results in a 60hz 2 frame lag. So either input is still being polled at 60hz regardless of frame rate, all my mice and track pads only operate at 60hz, or something else is causing this?

    ASHLEY. 2 frame lag isnʻt unreasonable, Iʻve got some 40hz and 144hz screens I can test on too and see if that changes things, but so far I am assuming there is a 60hz input buffer? Does construct do its own thing or does it build its buffer on another system?

  • I am not sure what you mean. I just tested (sprite set position to mouse.x/y) and the lag is barely noticeable at 60 fps. At higher fps there is practically no lag at all.

    In any case the lag can't be more than the duration of one frame, 0.016s at 60 fps.

    Does it happen in a blank project?

    Yes, it happens in a blank as well. I create a box and then set the box position to the mouse.x/y position.

    You can notice it most profoundly when moving the mouse in steady motions at the right speed.

    You can add several other objects that are daisy chained to the position of the the first, but set in reverse order so they each lag behind one frame. I use this to get an idea what several frames of lag should look like, but the mouse much further ahead.

    Ashley Iʻm curious if there is a particular hardware/software issue then. I donʻt think I would have noticed it if I hadnʻt been playing a lot of sc2 lately. Hopping from sc to construct and it was very noticeable .At some point in history, I knew firefox had less latency than chrome, and Iʻm not sure if that is still true, but I wondered how many layers input has to travel in a construct project being tied to the browser. Constructs input lag on my test, had to be perhaps 1/6 of a second or more, regardless of the FPS being vsynced or not. Whether the project was at 60fps or 22000fps. I wondered if constructs double buffer was daisy chained inevitably to several other double buffers? Iʻll try to get a screen capture when I am next at home.

  • Been messing around with RTS stuff, and I realized there is a massive gap between where the windows pointer is, and where mouse.x / mouse.y suggest that it is.

    I understood there to be usually only a few frames lag, but it seems to be the same gap, regardless of fps (vsync on or off).

    As it stands, it is basically intolerable from the stand point of RTS games (like starcraft). Can anyone tell me the variables the input lag depends on? Is it just the mouse, or does the keyboard have an equal delay? Is it possible to hack around this or does it reside in ther black box of either the construct engine or the web browser?

  • I've run a few more tests, since last on the forums. It seems we are on the same page.

    To handle velocity pointing the wrong direction, I just calculated sign(sign(targetDirection) + sign(velocity)). You can set up the maths to use it to cancel out a portion of the equation by multiplying with it like in shaders, or you can just use it as a condition. If 0, apply acceleration in the direction of the target, no matter what. Although if the velocity is near 0, as you mentioned you can still create a overshoot situation if not handled.

  • I would just do as you say in the OP - tween a value and reference it. Unless the tween behavior has a built in hook for it, that is pretty much your option afaik.

  • Using the following code, the object often overshoots its target. I believe variable time steps are to blame. The higher the max speed, the larger the overshoot in absolute terms, though it seems to stay relatively consistent . Often the overshoot is only a pixel or two, but its obvious. I also tried snapping to target when close enough and slow enough, but to work, the within range needs to be high, and is obvious.

    Is there an established way to deal with this problem in variable time step games? Ideally, I don't want to stop early, or begin decelerating any sooner than needed, but I wish to respect maximum acceleration/deceleration rates.

    //Acceleration and deceleration are equal. 
    DistanceToStop = (Velocity/Acceleration) * velocity * 0.5;
    DirectionToTarget = sign(Target - CurrentPosition);
    AccelerationThisTick = Acceleration * dt * DirectionToTarget;
    
    //reverse acceleration direction for brakes
    if (distanceToStop >= distancetoTarget) 
    	AccelerationThisTick *= -1;
    
    //Integration (doesn't make a difference between this and Euler - the overshooting //still occurs)
    CurrentPosition += (Velocity * dt) + (AccelerationThisTick * dt * 0.5);
    Velocity += AccelerationThisTick;
    
    

    Tagged:

  • Perfecto. Thanks, that works nicely.

  • Hey,

    I notice when defining aces that you can specify a parameter type to be a boolean. This is what I want, but in the editor, I want to be able to enter an expression when calling the action.

    ActionDoThing( Someotherthing.IsFlagSet ).

    Is there a way to to protect the parameter and force it to be a bool on the editor side without giving up flexibility and forces a checkbox?

  • Howdy partners,

    I was curious if it was intended for LOS behavior to only scan for image points rather than collision shapes.

    drive.google.com/file/d/1_M6Ti-S8A_pE9qQzDJLVTh-KkJH1h_-7/view

    I modified the example los project to demonstrate what I mean. The green line shows where a raycast is hitting a piggy, while the highlighted piggy is intersecting with los cone (set to 1 degree atm).

    You can see that while the ray intersects with the collision shape, the los cone seems to only scan for image points. I assume this is intended, but it does allow rather large objects to "hide" simply by keeping the image point hidden.

  • Hi all,

    I was wanting to replace a lengthy property list on a behavior with some sort of data injection.

    Ideally, I wanted to clear off as many instance variables as possible and just reference a single source of data (for example: Instead of having maxHealth property, I would just reference entity type, and lookup the maxhealth in a single source, instead of duplicating it on every instance.

    I'm looking to have minimal properties for the behavior and be able to simply have one property that lings to the relevant data (array, dictionary, Json, I don't really care).

    Is there an official way to do this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I should also add that I'm not looking for a full on "found in the wild" example either.

    Literally just one line, as WackyToaster mentioned.

    So in this example, the code would literally just be the ace declaration with the parameter in use that makes it static.

    The only code snippet is for the most basic declaration:

    {
    	"id": "every-tick",
    	"scriptName": "EveryTick"
    }

    I would assume I just do this to add the static property:

    {
    	"id": "every-tick",
    	"scriptName": "EveryTick"
    	"isStatic": "True"
    }

    But should the script name reference a function on the typeclass or the instance class? Idk. Does it even actually matter?