# Raycast will not hit generated box colliders at initialization

In my map class I have an algorithm that is generating and merging box colliders together. These belong to the layer "Ground".

After that, in some places on my map I'm generating some new cubes on-the-fly, and some of these cubes I don't want to generate at all. So, I'm doing a raycast to determine if they should be added or not.

I'm doing these raycasts to check if the position they should be generated at have free space to the left and right. For both rays I'm checking if they hit a collider beloning to the layer "Ground".

But I don't get a hit at all!

I've tried to create two cubes in the editor and assign them to the layer "Ground". If I run the game then I get a hit between these two cubes. But I will never get a hit checking against my generated colliders.

I do this logic in the Start-method, is there any certain method in the life cycle when I can start to use my generated box colliders?

• You want to make sure that Ground is being finished before starting to generate the additional cubes, is that correct? – Nikaas Jul 1 '16 at 10:49
• -1 It's too unclear what you are asking. – S. Tarık Çetin Jul 28 '16 at 16:00
• It would help to see a screenshot of the situation, and a snippet of code where you're doing the raycasting. It's easy to get false negatives from raycasts accidentally, but we won't know whether that's the issue until we can see exactly what you're doing. – DMGregory Aug 1 '16 at 14:06

Assuming you're trying to coordinate the Start() method of various scripts, you can ensure they execute in the order you want by going into the menu at Edit > Project Settings > Script Execution Order.
The fix was simple. I added a capsule collider, and continuously checked for collision using OnTriggerStay().