C2's Particles can rotate in very specific circumstances

0 favourites
  • 3 posts
From the Asset Store
Particles support animations, collisions, effects and etc.
  • I just discovered something pretty weird about C2's Particles object.

    In some strangely specific circumstances, the particle images actually will rotate.

    Expected behavior:

    The native C2 Particles object, for rendering optimization reasons, doesn't provide rotation options for the particle image.

    So, if you rotate a layer, say 45 degrees, (e.g. to simulate camera rotation), with a Particles object on it, the particle images will not rotate with the layer, and will instead stay oriented upright to the monitor.

    Weird behavior:

    However, there is a weird case where they will rotate with the layer.

    If the Particles image dimensions are 256 x 256, and the Particles Size property is 256, and the layout is scaled up by any factor greater than 4 (e.g. 4.001), then the particle images will rotate with the layer, as if they were inheriting their orientation from it.

    This is the only case I've ever seen that causes Particle images to rotate.

    I suspect it may have something to do with the particle sprites being large enough that they can't entirely fit in the renderable canvas area. e.g. Using 512 x 512 images and a layout scale of 2.01 will also cause the layer-inherited rotation.

    Example Capx:

    https://www.dropbox.com/s/72r6sibcytwem ... .capx?dl=1

    In case anyone is interested. :)

    Steps to reproduce:

    Objects:

    Create a native C2 Particle object.

    Set it's image dimensions to 256 x 256.

    Draw a vertical bar for the image.

    Set the Particles "Size" property to 256.

    Create a simple tiles grid backdrop. (So it will be easier to see the layer's rotated orientation.)

    Add Mouse object. (Just need to use the buttons for interaction.)

    Events:

    At start of layout, Set layer angle to 45 degrees.

    On Click Left, Set layout scale to 4.1

    On Click Right, Set layout scale to 3.9

    Now preview the game, and click the left and right mouse buttons to see the particles alternate between un-rotated, and rotated.

    Any idea what's going on here?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • When i was last poking around C2's renderer i noted that particles have two ways they can be rendered. Typically they are rendered as points, but when they are bigger they are rendered as quads. I'm guessing the quads will rotate.

    Why the two different ways? Webgl, or graphics cards for that matter, have a limit on how big they can draw points, so when C2 wants to draw points bigger then it has to use quads. Also the limit varies from graphics card to graphics card. On my machine both scaling factors are rotated.

    You can see this done in the particles drawgl function. And here are the stats of the supported point sizes:

    https://webglstats.com/webgl/parameter/ ... SIZE_RANGE

  • Interesting. Thanks for the info

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