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

Get help using Construct 2

Post » Fri Jul 08, 2016 12:26 pm

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!
Last edited by Pezito on Fri Jul 08, 2016 1:19 pm, edited 1 time in total.
B
8
S
1
Posts: 15
Reputation: 470

Post » Fri Jul 08, 2016 12:43 pm

[Tilemap is on layer 0]
--- Disable solid

That should work^

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
80
S
34
G
40
Posts: 3,029
Reputation: 30,393

Post » Fri Jul 08, 2016 1:07 pm

... 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! :P

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 ! :D

Anyway, thanks a lot SoldjahBoy. I can move on – until next time! ^^
B
8
S
1
Posts: 15
Reputation: 470

Post » Fri Jul 08, 2016 1:17 pm

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 :D

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
80
S
34
G
40
Posts: 3,029
Reputation: 30,393


Return to How do I....?

Who is online

Users browsing this forum: ksiads and 2 guests