// Use this for initialization
    void Start()
    {
        Camera        thisCamera    = GameObject.Find(gameObject.name).GetComponent <Camera>();
        GameObject    EventSystem   = GameObject.Find("EventSystem");
        cameraChanger cameraChanger = EventSystem.GetComponent <cameraChanger>();

        cameraChanger.cameraList.Add(thisCamera);
    }
예제 #2
0
 //setup
 void Awake()
 {
     myCamFocus = GameObject.Find ("Camera Focus").transform;
     focusControls = myCamFocus.GetComponent<cameraFocusControls> ();
     camFocusLocation = myCamFocus.position;
     inventory = GetComponent<PlayerInventory> ();
     if (GetComponent<playerIslandGrow> () != null) {
         islandGrower = GetComponent<playerIslandGrow> ();
     }
     camChange = GetComponent<cameraChanger> ();
     anim = GetComponent<Animator> ();
     rb = GetComponent<Rigidbody> ();
     //create single floorcheck in centre of object, if none are assigned
     if(!floorChecks)
     {
         floorChecks = new GameObject().transform;
         floorChecks.name = "FloorChecks";
         floorChecks.parent = transform;
         floorChecks.position = transform.position;
         GameObject check = new GameObject();
         check.name = "Check1";
         check.transform.parent = floorChecks;
         check.transform.position = transform.position;
         Debug.LogWarning("No 'floorChecks' assigned to PlayerMove script, so a single floorcheck has been created", floorChecks);
     }
     //assign player tag if not already
     if(tag != "Player")
     {
         tag = "Player";
         Debug.LogWarning ("PlayerMove script assigned to object without the tag 'Player', tag has been assigned automatically", transform);
     }
     //usual setup
     mainCam = GameObject.FindGameObjectWithTag("MainCamera").transform;
     dealDamage = GetComponent<DealDamage>();
     characterMotor = GetComponent<CharacterMotor2>();
     //gets child objects of floorcheckers, and puts them in an array
     //later these are used to raycast downward and see if we are on the ground
     floorCheckers = new Transform[floorChecks.childCount];
     for (int i=0; i < floorCheckers.Length; i++)
         floorCheckers[i] = floorChecks.GetChild(i);
 }