- Home /
Question by
akguldeniz · Apr 29, 2014 at 03:51 PM ·
raycastchecksurface
detect which surface touching by raycast
hi guys. im trying to do build block mode something like in minecraft.
my problem is blocks are not align at the same line. for doing this i need to findout ray touching the which surface of the existed block.
my script working with sendmessage:
if(hit.collider.gameObject.name == "stoneBlock(Clone)"){
gui.yazi = "Block";
hit.transform.SendMessage("position", 1);
}
and receiver for now:
function position(i:int){
if(i == 1){
Debug.Log(transform.position);
}
}
any ideas for receiver?
Comment
by the way my raycast direction is Vector3(0,0,1). its always look forward with camera
Best Answer
Answer by Jeff-Kesselman · Apr 29, 2014 at 04:05 PM
Get the collision vector from the Hit.
Compare it to the forward vector of the block's transform.
thanks i found out the way now i need to find out how can i get coliision vector from hit object. but i get it thank you
Your answer
