Optimized collision detection and parallax rate?

0 favourites
  • 6 posts
From the Asset Store
Detects any kind of ad blocker. Very easy implementation into already existing projects
  • I gather that C2 does some kind of spatial binning based on the project's window dimensions to optimize collision detection.

    If I set all layers to use a 50% X and Y parallax rate, all layers will still always be in alignment, but will this disable optimized collision detection across all layers?

    That is, will layers use optimized collision detection between each other if they line up, or only if they are at exactly 100% X and Y parallax rate?

  • I don't know for sure, but I know when I messed with parallax and having objects on different parallax layers interact with one another (not through collision) I always had to do a calculation to "line them up". I used a simple lerp function based on the Parallax of a given layer.

    If you are doing collisions I would highly recommend them being on the same layer.

  • Thanks for the reply jobel,

    Yeah, I don't plan to have misaligned layers with collisions between them, I agree that could get ugly.

    What I mean is if I have, for instance, just one layer, and it's parallax is set to 50%, will that disable optimized collision detection for everything on that layer?

    And the slightly more complex scenario is, if I have two layers both set to 50% parallax, so both layers are still always in alignment at all times, will the 50% setting disable optimized collision detection for everything on both layers?

    I'm just not quite sure what situations cause C2 to forgo optimized collision detection. I think it might only use the optimization for layers at 100% parallax, and will brute-force anything else. That might kind of make sense, as there may be only one data structure handling spatial binning, instead of one data structure for each parallax configuration found in the layout.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I doubt it would matter 2 layers opposed to 1 but as far as 50% parallax optimization.. I have no clue..that's probably an Ashley question..

  • It's all described in my blog post on collision cell optimisation. In theory it could still use collision cells if all layers have the same parallax, but in practice due to the way it's implemented it only uses collision cells on layers with no parallax (100%, 100%), and further, all instances of the object type must all be on layers with no parallax. A single instance on a parallaxed layer causes it to disable the entire optimisation for that object type, since it can no longer guarantee that collision cells line up.

    Besides, putting all layers to 50% parallax is pointless: just scroll half as fast with 100% parallax.

  • Hey Ashley,

    Thanks for the reply. I figured that might be the case. It makes sense that it would be set up to work just on the 100% parallax layers, as that's going to be pretty much all the practical cases.

    As for setting all layers to 50% parallax, I agree that that would be pointless, I was just using it as a simple example of paired layers with matching parallax.

    I actually happened to be faced with a special case that is related to that example, but a little more complicated, in which I would have several layers that would have variable parallax rates, but the parallax rates would always all be the same value across all the layers, or at least all the layers for which collision detection matters.

    Reason being, I figured out a way to scroll layers completely independently of each other, which I've been interested in for a while, but the method involves keeping the scroll coordinates fixed and adjusting the parallax scales of each layer instead. The parallax scales for each layer become the individual scroll coordinates for that layer. It works, but I was worried that the weird parallax values would break the collision optimization, and it sounds like they would. In this case the game world layers would all have the same parallax scales, and would stay lined up, but they wouldn't always be set to 100%.

    The main reason I've been interested in scrolling layers independently is that I'd like to be able to have a "game" world that scrolls normally, and an overlay-able "menu" system that can scroll from page-to-page independently of the game world. Currently there's no way that I know of to decouple the scrolling of the menu layers from the scrolling of the game world layers.

    I'm aware that it's technically possible to make a system that kind of approximates the en-mass coordinate shifting that layers can do, but it seems a bit tricky to make it play well across multiple object types, and with anything else that effects coordinates, like behaviors, or for that matter Particle object particles, which don't move with the source object.

    I've seen some other threads talking about independently scrolling layers, and it sounds like it's not currently planned. For what it's worth, I think it would be a cool feature, but I can also definitely understand why it might not be a priority.

    In any case, thanks again for the info.

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