i have a cube in my scene then i have attache one script to that cube which is have the multiple raycast function left side raycast right side raycast and up wards but this three function not working properly. Really is this possible for doin unity scripting?
this is my code i attached this to my cube. according from this code its raycasting right, left and top if any object reach its among any sides it should be do some function but its not working. What i want means i move this to any other object corresponding raycast should be work. But now its not.
RaycastHit hit;
if(Physics.Raycast(transform.position, Vector3.right, out hit, 0.50f)){
print("This is the right raycst function");
}
else{
}
}
else if(Physics.Raycast(transform.position, Vector3.left, out hit, 0.50f)){
if(hit.collider.gameObject.tag == "Plane"){
print("This is the left raycst function");
}
else{
}
}
//
else if(Physics.Raycast(transform.position, Vector3.up, out hit, 0.50f)){
if(hit.collider){
print("This is the up raycst function");
}
else{
}
}
else{
}