How do I stick a block next to another

Get help using Construct 2

Post » Wed Apr 15, 2015 8:30 pm

Hello
how can i stick or pin a block to an other which is the same object?
i want to make a game with blocks in it and i want to be able to pin a block to an others bottom or side.
B
7
S
2
Posts: 13
Reputation: 563

Post » Thu Apr 16, 2015 5:17 pm

if you have a bunch of the same objects, you need to select the individual object before you can assign it an Action. Otherwise you will make all the objects do the same Action.

so: 'For Each <object>' cycles through all the objects and you can assess each one at a time. or you can filter them by some sort of compare. Use the IIDs since that is unique and a way to identify each one.

for your block scenario you need to create some instance variable that tells whether the block is currently in it's "stuck" state. I'd also have another variable that states if that block is the one everyone else is stuck to. Although it depends on your design..
B
88
S
29
G
14
Posts: 1,143
Reputation: 14,981

Post » Thu Apr 16, 2015 6:17 pm

Another method is to use families.

So you have your block object. Add that to a family (let's call the family BlockFam)

Then you can do..

if BlockFam is overlapping Block at offset (0, -1) then pin BlockFam to Block.

Very simplistic, but the complexity depends on what you're trying to achieve.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Thu Apr 16, 2015 9:23 pm

Thank you guys, i want to make a game similar of Junkbot this old lego game http://www.funnygames.in/game/lego_junkbot_1.html
but i dont want to use lego blocks.
B
7
S
2
Posts: 13
Reputation: 563


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, ColombageEnPLS, doriHOG, mrtumbles, rustomatic and 4 guests