Conditional Solids

Get help using Construct 2

Post » Tue Feb 07, 2012 3:51 pm

I have a question. I am working on a game and one of the mechanics that I want to implement is conditional solids. To explain what I mean, I will explain how they would be used. Your characters basic color is green; everything that is green in the level the player can interact with but not with anything else of another color, unless it is a color changing block, for this example it will be for pink. If the character hits this block, they change color to pink and then can interact with all the pink objects and not the green ones.
I know I shouldn't just use a collision detection condition and I can't just make a floor object that works with this because the levels themselves rotate around so the level would have to be all floor objects, allowing the character to stick to walls.
Any thoughts?
B
11
G
1
Posts: 12
Reputation: 1,243

Post » Tue Feb 07, 2012 4:16 pm

Why couldn't you set all same colored objects to a family, and have a family condition (new to r78) triggered in an event? Example.

Make a Family "RED"
Something happens to Set Family "RED" to 1

If Player on contact with Family "RED"
& Family "RED" = 1
--> Do whatever...

Why would this not work?
B
192
S
6
G
7
Posts: 213
Reputation: 10,178

Post » Tue Feb 07, 2012 4:44 pm

conditionalSolid.capx
Will you be able to guess the trick? :D
Last edited by Yann on Sun Sep 14, 2014 12:36 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Feb 07, 2012 5:54 pm

Thanks you two. I hadn't tried the family variables yet because I started working on this in r77, which I couldn't see how it would work. Anyway, thanks Yann, that helped slightly, but can you explain exactly how that works, because I have no idea how the lerp() function is working on this or with all the changes in animation frame work with this. I also have a question if this should work if the layer is rotated as well?
B
11
G
1
Posts: 12
Reputation: 1,243

Post » Tue Feb 07, 2012 6:02 pm

@OctaveEight
It uses a frame with "no collision polygon" to ignore collisions.

Although it doesn't work perfectly since C2 doesn't allow a frame to have no collision polygon. If you jump over the top-left spot of an "deactivated" platform the player collides with the tinny collision polygon, when you are expecting not.
Scirra Employee
B
129
S
45
G
15
Posts: 705
Reputation: 15,413

Post » Tue Feb 07, 2012 6:45 pm

hehe yeah that works how he explained
the lerp is just to set opacity according to animation frame
if frame = 0 (with collision) opacity = 100
if frame = 1 (with the collision trick) opacity = 50

And it won't work with layer rotation as collision doesn't get rotated.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Feb 07, 2012 7:53 pm

Well, I'll have to try it that way anyway or do it with a families method, but thanks anyway. It helped a lot :D
B
11
G
1
Posts: 12
Reputation: 1,243

Post » Tue Feb 07, 2012 8:14 pm

Maybe I'm missing something - couldn't you just set the solid enabled property to disabled?
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Tue Feb 07, 2012 8:23 pm

Umm... I forgot you could do that :D Thanks Arima! :D That made it like 20 times less of a hassle :D
B
11
G
1
Posts: 12
Reputation: 1,243

Post » Tue Feb 07, 2012 11:40 pm

Heh I was going to suggest that too - maybe people miss that the Solid behavior actually adds a 'Set enabled' action you can use to enable or disable it :)
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Next

Return to How do I....?

Who is online

Users browsing this forum: h1k3 and 17 guests