Skip to content
Matt Javaly edited this page Feb 25, 2017 · 17 revisions

Swivel interactions allows cubes and imported 3D models to behave like doors.

Adding Swivel Interactions To Basic Cubes

There are two use cases for this interaction, the first of which is Unity's basic Cube object. This case is fairly simple, because the Box Collider used by the interaction already comes attached to Unity's basic Cube:

Now that we've got our Cube and Box Collider, we can resize the Cube to look like a door, and attach our Swivel interaction:

Our cube now functions as a door! The "Open From Left?" flag has not been checked, so this one opens from the right:

Note: if you want your door to open in the opposite direction (e.g. pull instead of push), just turn it 180 degrees on its Y-axis! You can do this in the "Transform" section of the editor:

Adding Swivel Interactions to 3D Models

As you develop your game, it may make more sense to include a more detailed door object instead of Unity's standard Cube. Luckily, Unity's Asset Store is a great resource for a variety of 3D models. Using Swivel with these door models is similar to the cube example above, with a few extra steps. First, the model may not come with a box collider, and if it does, the collider may not match the actual dimensions of the object like it did with our cube. To fix this, we must attach a box collider and size it to match our door model.

Notice how the Box Collider doesn't fit the shape of the door. If we attach our Swivel now, it won't know what the door looks like! So we resize the Collider like this:

The Collider doesn't have to perfectly match the door's shape, but the closer it is, the more natural the open and close will look. After we attach our Swivel, our door functions as it should!