I’m having an odd issue. This method works just fine to change the blockFace variable; however, once I change the rotation of the block it will only change blockFace on the face that hasn’t rotated. For example,
If I place a block with default rotation, blockFace updates correct on every face. If I rotate the block (0, -90, 0) blockFace only updates when I’m raycasting on the top of bottom face (which hasn’t changed). The hitPositionLocal variable shows that blockFace should be updating correctly.
I can’t seem to figure out what is going on. Can anyone help me out. If the way I am doing this is the problem could you suggest another way. The reason I do this is so I can detect which face of the block I am raycasting since not all blocks can have another attached to certain sides.
I think highlightedBlock.transform.InverseTransformPoint gives you floating point errors when block is rotated causing hitPointLocal.z==0.5 (z,y,x - all of them) to never work (as it might be 4.99999999 or 5.000000001 - that’s not ==0.5). Try to change those checks to something like Mathf.Abs(0.5 - hitPointLocal.z)<0.01f (0.01f is arbitrary; you can decrease it further).
I actually thought that might be the case last night but needed to sleep. I completely forgot so thank you for replying and reminding me lol. I’ll let you know if it works when I get a chance to try.