hi, i have some problem on my main camera.
In my game,my character is created after login using instantiate, so the target have to been set inside the script.
when i press i j k l, my character will move which have been done in the other script.
and the script for the main camera is as below.
while only the key u and o work as expected,
and the i j k l give my unexpected effect,
it seem not set behind my character.
void Update () {
if(!targetset){
GameObject[] players=GameObject.FindGameObjectsWithTag("player");
//Debug.Log(players[0].name);
foreach(GameObject temp in players){
if(MemberGlobal.Nickname==temp.name){
player=temp;
}
}
}
if(Input.GetKey("i")||Input.GetKey("j")||Input.GetKey("k")||Input.GetKey("l")){
mainCamera.transform.position=new Vector3(xoffset,yoffset,zoffset)+player.transform.position;;
}
if(Input.GetKey("u")){
transform.RotateAround(player.transform.position,Vector3.up,-2f);
}
if(Input.GetKey("o")){
transform.RotateAround(player.transform.position,Vector3.up,2f);
}
}