Hi,
Been breaking my head on this the last few hours. Been googling endlessly, couldn’t find what I needed.
Basically, I’m building a puzzle generator which places 2x1x1 blocks on a 5x5x5 grid. Position is random and rotation is random in increments of 90. Now, because my block has its pivot on the center of 1 half of the block I need to raycast into the other half of the object to check if there’s something in the way which would cause it to be in another object when it’s going to spawn. Alas, that’s not the problem, it’s actually working fine.
However my problem is that I’m having issues getting the right Raycast Vector3 direction. I’m managing the spawning and raycasting from a seperate manager object.
What I’m doing is:
- Get random spawn position
Problem > 2. Raycast from random spawn position
to up to check if there’s something ahead
-
Spawn if there isn’t
-
repeat if there is
However because I dont have access to the spawned gameobject yet I’m having issues getting the right direction for the Raycast to go.
What’s the best way for me to get the Raycast direction from step 2? I’m out of ideas at this point.
Thanks