How to use MouseOrbit?

I am having a hard time trying to use Standard Assets MouseOrbit.

I created a floor and a cube on top of it.

I then attach the MouseOrbit script to the cube. I then move the Cube as the target.

The cube falls down when I play.

How should I use it?

Thanks in advance for your help.

This is not MouseOrbit’s fault - this script just makes the camera follow the target, and orbit around it when you move the mouse in the X direction. You did it right: just set the target to your object.

There are several possible reasons for the cube to fall through the ground, and some of the most popular are:

  • the cube is a CharacterController, but is a little below the ground level;

  • the cube has a rigidbody and a box collider, but this one has IsTrigger checked;

  • the cube has a rigidbody and a mesh collider, but this one has Convex unchecked;

  • you’ve assigned a CharacterController or other collider to the terrain by mistake, what killed the terrain collider (I did this stupid thing once…)

Try to investigate the problem step by step: disable the MouseOrbit script, place an inoffensive cube (without rigidbody) under your cube, delete and recreate the terrain, place your cube at some height to let it fall to the ground when the game starts, check if the cube position.y is above 0.5 etc.

EDITED: I’ve got it: you should attach the MouseOrbit script to the Main Camera, not to the cube! The script tries to position its transform behind the target - but since the target was itself, it would enter an endless loop.

But at least you were right: the culprit was MouseOrbit!