I'm trying to rotate a door gameObject using the transform.RotateAround method and I'm getting some weird behavior. Now, before anyone asks, I'm doing it this way instead of using an animation for a reason, so please don't tell me to use an animation instead. Instead of behaving as a door should, the door comes off of the point where its hinge should be and rotates further off into the distance with each mouse click. Here's a snippet:
hinge is the Vector3 to rotate around
AngleToOpen is the angle I want to rotate the object to
Try rotating a smaller object around the hinge (think of it as the door hinge part) then child your door to this smaller object so that it moves in rotation with the hinge.
Example:
Image Link :
(quick and cheesy door example picture ;) )
Basically here's what you 'could' do.
You have your door frame a hinge on the frame, a hinge on the door and the door.
You then rotate the hinge on the door around the hinge on the door frame.
/////////////////////////////////////////////////////////////////////////////////
//
// ThisOpenDoor.cs
// Created: Darren Hedlund microcyb@gmail.com
//
// description: Script to open a door when the Player is near
//
// Note: To change the pivot point use this URL by VoxelBoy.
// http://solvethesystem.wordpress.com/2010/01/15/solving-the-pivot-problem-in-unity/
// or create a seperate Empty GameObject and attach door mesh to it
/////////////////////////////////////////////////////////////////////////////////