[solved] How do I collide a tilemap used on several layers?

0 favourites
  • 4 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hi,

    I'm making a top-down game much like The Legend of Zelda and I'm not sure how I should design collisions.

    Here's what I've done so far:

    – import an image containing all my tiles;

    – add a tilemap object to my layout;

    – add an instance of that tilemap on layer 0;

    – add another instance of that tilemap on layer 1;

    – fill the tilemap on layer 0 with tiles that don't collide;

    – place the tiles that do collide on the layer 1 tilemap;

    – add the player's sprite on layer 1;

    – add "solid" behavior to the tilemap instance on layer 1;

    – add "8-direction" behavior to the player's sprite.

    Now what happens is that my sprite can't move at all... unless I delete layer 0. Then and only then, the "8-direction" behavior acts as intended, the sprite moves and collides with the tiles on layer 1.

    How can I keep the tilemap instance on layer 0 while having my sprite ignore it when it comes to collisions? I didn't set a "solid" behavior on that tilemap instance. But my guess is that Construct checks for collisions with that tilemap anyway, because it's an instance of the same tilemap object to begin with – thus the sprite being unable to move, as it's on top of / inside some tiles which aren't meant to collide with it.

    So what should I do? I'm thinking of having two different tilemap objects, one used on layer 0 only and the other used on layer 1 only. They should be allowed to use the same image file no matter what, so I guess I won't end up with twice the same image in my project... Is that correct or did I miss something?

    Thanks for your help!

  • [Tilemap is on layer 0]

    --- Disable solid

    That should work^

    ~Sol

  • ... Yeah, that did it!! ^^

    When I read your answer I thought you misunderstood my question, like it couldn't be that simple... Well in fact, you were right!

    What misled me is the way these instances of my tilemap are managed by Construct. I thought they would either be handled as two independant entities all the time, or share the same behaviors and variables all the time. Turns out it's a bit of both!? I added the "solid" behavior to one of them only, but it was added to the other one as well without notice; if I then remove the behavior from one of them, it's removed from the other one too. However if I disable that behavior in one of the instances, it can remain enabled in the other one... See, this is what confused me. I just didn't think it would work that way !

    Anyway, thanks a lot SoldjahBoy. I can move on – until next time! ^^

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes when you use instances of the same object, any behaviour or instance variable you add to it will be used by all instances of that same object... but they can be set and controlled PER instance

    You're welcome! Glad that worked

    ~Sol

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