Do any of you know a script so that the user can change the center of rotation of objects in the game mode?
For example, I have a parent object with several child objects. The main camera has an orbit, zoom, pan script attached to it, using the center of rotation of the parent object. In game mode, I would like the user to be able to click on the RMB to:
Select one of the child objects in game mode
Highlight the selected child object in [specified] color
Change the camera center of rotation to the selected child object
Rather than raycasting you could also put a script on the target objects implementing OnMouseDown(). The objects will need colliders either way.
If you want to assure that only one object at a time is selected you can keep a static variable in the script referencing the currently selected object (or the script on that object), which you then deselect whenever a new selection is made.
the script would be called SelectTarget
static var currentSelection : SelectTarget;
function OnMouseDown()
{
if( currentSelection ){
currentSelection.Deselect();
}
Select();
}
function Select()
{
// highlighting and camera retargetting go here
currentSelection = this;
}
function Deselect()
{
// undo highlight, etc.
currentSelection = null;
}