- Home /
Rotate object to face away from wall
I have a game similar to the sims where you can place furniture and design your house. Now I'm stuck at placing of the wall furniture, things like windows or paintings etc.
Below you can see the picture frame model(Inside the red boxes) that I'm using for testing. The player selects the object and when he clicks within the boundaries of the room,it fires raycasts to check shortest distance to wall and then the object sticks to the wall closest to it.
I want the picture frame to rotate automatically to align with the wall it sticks to, I'm not good with rotations and Quaternions, but a quick google check tells me I'm looking for Quaternion.LookRotation? I'm not sure if it's the one I'm looking for and if it is I'm not sure how to use it. Any help is appreciated, thanks!
Answer by rmassanet · Jul 26, 2016 at 06:50 AM
You can modify the object's forward vector straight away.
So, in your case, after getting the raycast hit point, you could get its normal
property and set the object's forward vector to that normal.
Of course, for this to work, you need to make sure the object is built so that its forward face is the one you want the user to face.
Your answer
