how do i do this thing that will allow me to do other things

Get help using Construct 2

Post » Tue Apr 07, 2015 1:21 am

I'm looking to create a random dungeon generator, but being new I've hit a snag relatively early. So far I generate a room, and want to pick a single and random wall that is touching said room. However, all of the walls that are touching the room generate a door instead of only one, and do so in an (understandably) ordered way.

Also, using the "at start of layout" condition causes no doors to generate at all.

Image

Image

Is that enough information?
B
10
S
4
Posts: 24
Reputation: 804

Post » Tue Apr 07, 2015 2:11 am

Event sheets are read top to bottom, so if you use on start of layout then you need to make sure that your room is created before you look for overlaps to create a door. All events will be checked each tick (depends on your monitor rate, but usually 60 times per second) so if you don't have a trigger once or other limiting condition for something like this then your walls will be checked a lot... Also, because of the way that events work, you don't need the for-each loop as that selects each wall in turn and will create a door for each one that meets the or group criteria.

So... remove the for each loop and move the overlap check (events at line 2) and put them after the create room events (line 7 / 8) under the on start of layout.
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
73
S
19
G
66
Posts: 2,198
Reputation: 42,193

Post » Tue Apr 07, 2015 2:18 am

Colludium wrote:Event sheets are read top to bottom, so if you use on start of layout then you need to make sure that your room is created before you look for overlaps to create a door. All events will be checked each tick (depends on your monitor rate, but usually 60 times per second) so if you don't have a trigger once or other limiting condition for something like this then your walls will be checked a lot... Also, because of the way that events work, you don't need the for-each loop as that selects each wall in turn and will create a door for each one that meets the or group criteria.

Yeah, that's what I figured.

Colludium wrote:So... remove the for each loop and move the overlap check (events at line 2) and put them after the create room events (line 7 / 8) under the on start of layout.

That doesn't work. Instead, not a single room is generated. I'm thinking it attempts to generate it, but unless I get very lucky and RNG lands on the 20 or so applicable squares out of 1,000 possible I wont be seeing it.
B
10
S
4
Posts: 24
Reputation: 804

Post » Tue Apr 07, 2015 2:22 am

Are you able to upload a capx? It's almost impossible to guess what might be causing it not to work otherwise.
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
73
S
19
G
66
Posts: 2,198
Reputation: 42,193

Post » Tue Apr 07, 2015 2:47 am

here

thanks for the assistance btw, it is appreciated.
B
10
S
4
Posts: 24
Reputation: 804

Post » Tue Apr 07, 2015 3:07 am

Here you go! I've done some housekeeping with the events, to change the emphasis of the overlap check filters and to add a wait 1 tick event so that the first set of walls are destroyed before checking where to put the door. :)

link
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
73
S
19
G
66
Posts: 2,198
Reputation: 42,193

Post » Tue Apr 07, 2015 3:38 am

Great, thanks for the help. Though, can you tell me the significance of using an offset of five for the proximity checks? Seems arbitrary, but it works.

EDIT: oh, and i just noticed that doors occasionally spawn in the corners of the room which is illogical considering the player cannot reach it.
B
10
S
4
Posts: 24
Reputation: 804

Post » Tue Apr 07, 2015 11:03 am

Offset 5 just moves the room enough without creating the possibility of an overlap happening on wall objects that are not adjacent to the room; ie moves less than the wall object width.

I'll only be able to try this later, but for doors to appear inside the room then sometimes wall objects are not being destroyed first. Which is probably caused by asking too much of the engine in one tick/event when creating a lot of wall objects and then destroying some of them at the same time.

Try changing the events by moving the room overlap check and wall destroy events to be under a tickcount =1 condition. Then move the door create check events to be under a new tickcount =2 condition.

I think that'll work but I won't be able to check until later to be sure.
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
73
S
19
G
66
Posts: 2,198
Reputation: 42,193


Return to How do I....?

Who is online

Users browsing this forum: Darth Crusher and 11 guests