#Uthels Crappy Procedural Dungeon

1 messages Β· Page 1 of 1 (latest)

pliant briar
#

Anyone willing to give me a hand troubleshooting this?

#

Having two problems right now - can't get the checkbox I'm using to check if I can build a new room to go to the right spot, and on one of my prefab rooms, the left room spawner works, the right one does not, and I have no idea why, its oriented right as far as I can tell

#

ah nvm ill just keep pluggin away at it

onyx pond
#

Name the first problem first.

pliant briar
#

The first problem, is I am attempting to use Physics.Checkbox to determine if there's a room already in place before I spawn a room, but I think I'm having problems determining the origin placement for it.

#
if (!Physics.CheckBox(spawnpos.position + (spawnpos.transform.forward * 11), halfextents))
                {
                randroomid = Random.Range(0, rooms.Length);
                newroom = Instantiate(rooms[randroomid], spawnpos.position, spawnpos.rotation);
                dungeonController.currentrooms += 1;
                }```
#

11 was the shortest I could make it without it.. triggering on itself

#

halfextents is 2,2,2

onyx pond
#

Haven't heard of Checkbox before, let me do a quick research

pliant briar
#

from what I understand, it's basically the same thing as CheckSphere πŸ˜›

onyx pond
#

It seems that it's colliding with your checkerboard.

#

See if ignoring raycast on the board itself might help resolve the first issue.

#

Or add a filter to omit the board, but do check and see if you are still on the board.

pliant briar
#

yeah - the first arguement in checkbox designates an origin, so I'm trying to set it to.. some distance in front of the spawn position

#

well, I think I need the colliders to be able to determine if something is there

onyx pond
#

Second, does the spawnpos move?

#

From the spawn pos, you're checking in front of the spawnpos * 11 metric unit.

pliant briar
#

not relative to the prefabs, they each have their own spawnpos and scripts

onyx pond
#

I see

pliant briar
#

the rooms are 10x10, so the number I'd assume I'd want to use would be 5, since there's no colliders on the little sphere and cube indicators, and I set a halfextent of 2, which should make a 4x4x4 cube

#

but anything lower than 11 triggers off itself..

onyx pond
#

Right...

pliant briar
#

and 11 doesn't do the trick, I get overlapping rooms occassionally

onyx pond
#

Are you always checking forward every time?

#

Will there be any checks on the side of the room?

pliant briar
#

there's two room prefabs - one with a forward facing outlet, and one with two sideways facing outlets, but they are all oriented appropriately

#

(since they spawn rooms in the right direction I assume their transform.forward is pointing the right way)

#

Potentially unrelated but maybe not, on the double outlet room, the left outlet works, the right one does not - no clear reason why πŸ˜›

onyx pond
#

how are you checking left and right?

#

I think that might be where it's bugged.

pliant briar
#

with transform.forward using a reference to the spawn position transform

onyx pond
#

Ok so, the left and right have their "own" spawner? script?

#

make sure that you set to "Local" instead of "World" and see if the gizmo's blue ray is exactly where you want your spawner to check.

pliant briar
#

yeah, both spawner and script - same script, but using a different transform reference

#

hmm

pliant briar
onyx pond
#

Well in your left/right room, find the gameobject that have the script attached, then take a look at the gizmos when you select the "Move" tool, or press w on your keyboard.

#

See which way your gizmo is facing.

#

Also real important, is to make sure you have Local set, not World.

pliant briar
#

... apparently forward isn't blue, it's the opposite of red?

#

blue arrow is def not forward anyways..

onyx pond
#

blue is forward

#

red is right

pliant briar
#

haha you were right after all - I came to the realization that my rooms weren't oriented back to front, but left to right - all of them, in fact, in the prefabs - the negative red being the direction I wanted to be forwards was the clue

#

so my solution, since transform.forward wasn't going to work

#

if (!Physics.CheckBox(spawnpos.position + ((spawnpos.transform.right * -1) * 5), halfextents))

#

πŸ˜›

#

and that works πŸ™‚

#

also solves the right hand room spawner on the two-spawner room not working, for reasons that are now clear

#

Many thanks mm, problems solves, onwards and upwards!

#

solved*