#Dungeon Generation

1 messages · Page 1 of 1 (latest)

solemn summit
#

I’m having some trouble with my Dungeon rooms I want to add items in the rooms but I’ve ran into the issue of the objects clipping into the walls and certain objects that need to be on the wall might also do the same.

#

Is there a way I could have a detection for when an object is near a wall, and for things that are torches is there a way I could have it snap to a wall closest to the prop spawn point?

visual linden
#

well, in this case, you just need to make sure that you don't pick a point that's too close to a wall

#

If a room is square, you can easily calculate a Bounds object that covers the floor

#

if you give each prop a radius, you can shrink the bounds by that much before randomly sampling a position

#

You can also use the physics system here. Use Physics.CheckBox to see if anything is in the way before spawning the prop

#

note that if you're just moved an object via a script, you may need to use Physics.SyncTransforms() before doing any more physics queries

#

or you'll be doing queries against an outdated view of the world

#

I use this kind of thing extensively in a procedural generation system I built for VRC worlds

#

(i also put trigger colliders near doors to prevent random clutter from blocking them)

visual linden
#

in my system, everything you can spawn has a SetupRoot on it

#

which includes that information (and runs other setup logic)

rancid flower
#

without physics you can really just set your index has walls already and check neighbor indicies

ex. tiles[0,1] northWall = true, eastWall = true, southWall = true, westWall = true.

so now when [0,2] is created it checks all neighbors, and since [0,1] in this case is north of it, it'll compare against its southWall and since it's true it won't create a new wall.

#
  • some logic if you want to make a wall with door or not
solemn summit
#

My system is sort of set up like that each wall is made of of 3 game objects and the wall with the door on it has the door under it. Pretty much like a bunch of puzzle pieces

Looks kinda like this in the Hierarchy

Entrance - East

endWallLeft
wallEntrance

doorWall
doorOutline
Door
endWallRight