So I was wondering if I could do something with a script to basically access different side of a cube. So what I want to achieve is being able to know if there is another cube touching a certain side of the cube. And doing a list of things after that. Is there anyway to do this? Or do I have to make a complicated cube with separate colliders for each side?
Anyone?
Sure, whatever it is you’re asking about, it can be done
That said, I’m not entirely sure what you’re asking about; perhaps you could provide some more info.
Generally speaking though, there are many ways you could determine whether two cubes are adjacent, and if so, which faces are shared between them.
one way would be shooting short rays (cube size long) in the directions you are interested, to see if they hit another way.
another way would be to represent the grid as an array and store a referece of each cube in an array. You would write grid[×][y] to see if there is a cube at this location. Having an array of references might be helpful for the rest of your logic as well
So hwo would I write a java script to do all of teh rays?
It’s actually not ‘a java script’; rather, the language itself is called JavaScript (aka UnityScript). So if anything, it’s a ‘JavaScript script’
As for your question, I would favor a grid-based approach (as previously suggested) over raycasting if possible. (Still not sure what you’re trying to do exactly though, so I can’t really say one way or the other whether a grid-based approach would be appropriate.)
I halfway answered this question in another thread…
http://forum.unity3d.com/threads/82342-Dupliating-a-game-object.?p=526825&viewfull=1#post526825
Look it over, it all has to do with the normal that you get from the RaycastHit. For the hit it’s self, you would probably want to do an InverseTransformPoint on the cube to get a normal that means something if it is rotated.