How do I populate an scene with objects

Get help using Construct 2

Post » Wed Jun 29, 2016 2:08 pm

The way I did the my climb is like this, obviously there's some missing code just on top of this for when key is released while grabbing a ledge.
Also the On Timer "hangTime" in which I set isGrabbing to False as well. That way player can fall from a ledge by releasing a key or by staying too long grabbing one.

https://www.dropbox.com/s/20c8kb1tgbst3b3/code_01.png?dl=0

The collision helper I use is called climbDetect, and Player got an invisible sprite attached to it called handDetect. So when one is overlapping the other Player goes to grabbing state.

Now, since I have to place these ledge helpers everywhere manually, there's more chances of making mistakes, so that's why I'm trying to do it automatically.
B
43
S
12
G
14
Posts: 488
Reputation: 10,570

Post » Wed Jun 29, 2016 2:22 pm

Mmh, I didn't think my climbing with any sort of helper. Just detecting which areas around the player are overlapping or not the scenery, no tiles would be set as more climbable than others.
How badly are the helpers needed? I'm not familiar with these so I don't know how they help exactly.

In the meantime I'll try to put my code into exectution.
B
7
S
3
G
3
Posts: 56
Reputation: 2,240

Post » Wed Jun 29, 2016 3:35 pm

I doubt they are really needed but it was my solution at that time. Actually I wish I could do it differently lol. the helper is useful since its smaller than the Player controller therefore the overlapping area is smaller. maybe it could be done on code by detecting from an ImagePoint lets say an areaa of 8x8 pixels wide. I don't know how that would work though.
B
43
S
12
G
14
Posts: 488
Reputation: 10,570

Post » Wed Jun 29, 2016 6:23 pm

Ok so here is a method to spawn helpers for sprite objects. It will work even if every single tile is the same, but will reduce the loops required if your corners are already defined. Basically you check if your block is a corner, and then you check the space to the left or right of each one to see which side is open. Then based on that you will spawn your helper block at the correct position.

Set up: For your corner animation frame in your block object, make two image points, one in the top left and one in the top right.

Event:
For each BlockObject
Compare Values AnimationFrame is CornerFrame
BlockObject is NOT overlapping at offset BlockObject.Y+BlockObject.Height (Check to see nothing is above it)

Subevent 1:
BlockObject is NOT overlapping at offset BlockObject.X+BlockObject.Width (Check nothing is to the right)
Action: Spawn HelperBlock at BlockObject's imagepoint top right

Subevent 2:
BlockObject is NOT overlapping at offset BlockObject.X-BlockObject.Width (Check nothing is to the left)
Action: Spawn HelperBlock at BlockObject's imagepoint top left

Note that for this method if there is a single block by itself, it should spawn helpers on both sides. Up to you if you want that to happen or not. If you don't, you can add an ELSE to the second subevent.
Mistakes were made.
B
52
S
26
G
109
Posts: 1,615
Reputation: 61,651

Post » Wed Jun 29, 2016 7:00 pm

For each why I never thought about it.... I should go back to the basics again. Thanks @oosyrag
B
43
S
12
G
14
Posts: 488
Reputation: 10,570

Post » Wed Jun 29, 2016 7:54 pm

Sadly I arrive to same result as previously. Its spawned in both sides. I tried doing a checkup with variables but that didn't work either. It doesn't seem to take into account the overlapping condition.
B
43
S
12
G
14
Posts: 488
Reputation: 10,570

Post » Wed Jun 29, 2016 9:00 pm

Here you go. I got to experiment a bit and realized I left out the Pick All. Originally when you do For Each, only the active block is picked, so when you check if its colliding with any other blocks around it, it wouldn't because the only instance it sees in that event is the currently active one unless you use Pick All.

https://www.dropbox.com/s/88osdmr15uv1m ... .capx?dl=0

Not quite finished, as you can see with the one at the bottom of the U, but hopefully it will get you going in the right direction.

Edit: Still broken in several situations, I'll try to refine it a bit...
Mistakes were made.
B
52
S
26
G
109
Posts: 1,615
Reputation: 61,651

Post » Wed Jun 29, 2016 9:26 pm

Weird but still have the same issue, I even copy and paste by renaming the objects in your file to those of mine and yet gave the same result. I'm still checking what could be causing this
B
43
S
12
G
14
Posts: 488
Reputation: 10,570

Post » Wed Jun 29, 2016 9:41 pm

It seems like when you have object bounding boxes directly adjacent to each other they count as overlapping, so this solution might not work as I expected to at all. Gonna think of another way. But don't worry, I'm sure it can be done ;)
Mistakes were made.
B
52
S
26
G
109
Posts: 1,615
Reputation: 61,651

Post » Wed Jun 29, 2016 10:32 pm

@ oosyrag, (without families, took your capx) I think this are the rules.

https://www.dropbox.com/s/8vwxgc9aku4bu ... .capx?dl=0
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 51 guests