How to get the camera in the scene through script
Hi all,
I am still wet behind the ears when it comes to scripting at the moment but I am trying to learn by doing and looking at other scripts.
The issue I have atm is I have a character that is created and that all works fine, my next stage was to take the main camera (which has a script on it called CameraControl.cs). If I run it and manually target the created player and then enable it, it works and follows the character (it is very basic atm but thats all I want atm). I just cannot for the life of me figure out on the login script how to grab the camera, target the player and enable it (as that is what I am doing manually).
[code2=csharp]void OnJoinedRoom()
{
GameObject monster = PhotonNetwork.Instantiate ("Character_SP", Random.onUnitSphere * 5f, Quaternion.identity, 0);
SimpleControl controller = monster.GetComponent<SimpleControl>();
controller.enabled = true;
}[/code2]
This works and gives the network player control of the player spawned but I don't know how I can grab the camera which isn't on the spawned player.
Can someone give me some tips please?
Thanks,
Doomie
I am still wet behind the ears when it comes to scripting at the moment but I am trying to learn by doing and looking at other scripts.
The issue I have atm is I have a character that is created and that all works fine, my next stage was to take the main camera (which has a script on it called CameraControl.cs). If I run it and manually target the created player and then enable it, it works and follows the character (it is very basic atm but thats all I want atm). I just cannot for the life of me figure out on the login script how to grab the camera, target the player and enable it (as that is what I am doing manually).
[code2=csharp]void OnJoinedRoom()
{
GameObject monster = PhotonNetwork.Instantiate ("Character_SP", Random.onUnitSphere * 5f, Quaternion.identity, 0);
SimpleControl controller = monster.GetComponent<SimpleControl>();
controller.enabled = true;
}[/code2]
This works and gives the network player control of the player spawned but I don't know how I can grab the camera which isn't on the spawned player.
Can someone give me some tips please?
Thanks,
Doomie
0
Comments
-
I think the Marco Polo Tutorial can help. It runs into the very same issue and shows how to solve it.
http://doc.exitgames.com/photon-cloud/M ... 0Tutorials
Let us know if this helps.0