var MouseOrbitScript : MouseOrbit;
var selectedHood : Transform;
function Awake()
{
SelectHood(0);
}
function Start () {
MouseOrbitScript = GameObject.FindGameObjectWithTag("MainCamera").GetComponent("MouseOrbit");
}
function Update (){
if(Input.GetKeyDown("1")){
SelectHood(0);
}
if(Input.GetKeyDown("2")){
SelectHood(1);
}
}
function SelectHood(index : int){
for (var i=0;i<transform.childCount;i++){
if (i == index){
transform.GetChild(i).gameObject.SetActive(false);
MouseOrbitScript.target = selectedHood;
}
else{
transform.GetChild(i).gameObject.SetActive(true);
}
}
}
and the mouse orbit script that comes with unity and what im looking for the mouse orbit script on my camera to do is lock on the gameobject that the player select in this case different cubes serving as different neighborhoods. Thats one part of it the other part is I need each cube to be able to return information to the GUI’s on the camera once selected.
var MouseOrbitScript : MouseOrbit;
function Awake()
{
SelectHood(0);
}
function Start () {
MouseOrbitScript = GameObject.FindGameObjectWithTag("MainCamera").GetComponent("MouseOrbit");
}
function Update (){
if(Input.GetKeyDown(KeyCode.LeftArrow)){
SelectHood(1);
}
if(Input.GetKeyDown(KeyCode.RightArrow)){
SelectHood(2);
}
if(Input.GetKeyDown(KeyCode.UpArrow)){
SelectHood(3);
}
if(Input.GetKeyDown(KeyCode.DownArrow)){
SelectHood(4);
}
}
function SelectHood(index : int){
for (var i=0;i<transform.childCount;i++){
if (i == index){
transform.GetChild(i).gameObject.SetActive(true);
transform.GetChild(i).gameObject.renderer.material.color = Color.green;
MouseOrbitScript.target = transform.GetChild(i).gameObject.transform;
}
else{
transform.GetChild(i).gameObject.SetActive(true);
transform.GetChild(i).gameObject.renderer.material.color = Color.white;
}
}
}
but how would i get the left and rights arrows and up and down arrows to cycle thru the index, its 120 [GO’s] to cycle thru anyone know what im getting at?