0 Favourites

imprecise x and y positions causes glitches

  • Hello!

    I'm working on a platformer game and have discovered a problem. When running the game in debug I saw that object does not have an exact position. example: The floor is placed with an Y position of 128 but when I inspect it in debug it has an y position of 127.9541354174. This causes annoying glitches in the player(set to be global) animations when switching to next layout, the falling animation is played for a fraction of a second before returning to normal because the floor in the next layout is also set with y value but not the same as the first one. Why is C2 setting the floor to 127.9541354174 instead of 128?

  • I never had such problem so I'm not very familiar with this topic, but the first thing that came to my mind was pixel rounding project property. Do you have it ON?

    From the manual:

    [quote:3s84v972]Pixel rounding

    By default Construct 2 objects can be drawn at sub-pixel positions, e.g. (100.3, 200.8). If the browser is using linear filtering, this can make fine pixel art appear blurry. If Pixel rounding is set to On, Construct 2 objects round their position to a whole number before drawing, e.g. (100, 201). This prevents any blurring, and can also prevent "seams" appearing on grids of objects. Note this does not affect their actual X and Y co-ordinates, which can still be between pixels - it only affects where they are drawn on the screen.

    https://www.scirra.com/manual/66/projects

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • I never had such problem so I'm not very familiar with this topic, but the first thing that came to my mind was pixel rounding project property. Do you have it ON?

    From the manual:

    [quote:hxhc60bv]Pixel rounding

    By default Construct 2 objects can be drawn at sub-pixel positions, e.g. (100.3, 200.8). If the browser is using linear filtering, this can make fine pixel art appear blurry. If Pixel rounding is set to On, Construct 2 objects round their position to a whole number before drawing, e.g. (100, 201). This prevents any blurring, and can also prevent "seams" appearing on grids of objects. Note this does not affect their actual X and Y co-ordinates, which can still be between pixels - it only affects where they are drawn on the screen.

    https://www.scirra.com/manual/66/projects

    Yes Pixel rounding is on (using the retro style template)

  • Done some more testing. Found out that objects with physics behaviour, even if set to immovable renders the pixel rounding option useless. So I turned of physics for the floor but the glitch was still there, turns out that the players platform behaviour also is part of the problem since it never lands with a whole number on the Y axis. So anything with any kind of movement behavior completely disregards pixel rounding.

  • You have two options.

    Either snap the objects to whole numbers using events.

    Or don't check exact coordinates, check if it's within an area. ><

  • It is problematic in did, and definitely happens when game is upscale, but not sure if the problem exists if displayed in original window.

  • You have two options.

    Either snap the objects to whole numbers using events.

    Or don't check exact coordinates, check if it's within an area. ><

    Can you give a short explanation on how to snap positions?

  • For a grid its:

    int(self.x/n)*n

    Where n is the nearest number to snap to.

    Otherwise just use set x to int(self.x)

  • For a grid its:

    int(self.x/n)*n

    Where n is the nearest number to snap to.

    Otherwise just use set x to int(self.x)

    Thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
42 5,110
Jayjay's avatar
Jayjay
Unread hot topic
35 1,990
megatronx's avatar
megatronx
Topic
22 812
Ashley's avatar
Ashley Construct Team Founder