I have a method that do a raycast to a wall, and return the out hit.normal. Then, apply to object so it can rotate in the right position.
The problem I was facing before this workaround is that to get my rotation right, I needed to manually rotate the object 90 degrees on the x axis. To prevent this, I come with this manual change on the out hit.normal.
I think is badly implemented, but works. After the raycast, took out the out hit to Vector3 myhit
normal = myhit.normal;
//flipping the normals
float x = normal.x;
float y = normal.y;
float z = normal.z;
normal.x = x;
normal.y = -z; //needed to flip
normal.z = y; //needed to change
Object code for rotate
public GameObject tempghost;
tempghost.transform.rotation = Quaternion.LookRotation(normal);
Its working, but I feel like its wrong, and its possible to generate errors in the future…