I want the camera to follow the player but I dont want the camera to rotate when the player is turning. This is the entire script :
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class SetupLocalPlayer2 : NetworkBehaviour {
[SyncVar]
string pname = "Player";
void OnGUI()
{
if (isLocalPlayer) {
pname = GUI.TextField (new Rect (25, Screen.height - 40, 100, 30), pname);
if(GUI.Button(new Rect(130,Screen.height - 40,80,30),"Change"))
{
CmdChangeName(pname);
}
}
}
[Command]
public void CmdChangeName(string newName)
{
pname = newName;
this.GetComponentInChildren ().text = pname;
}
void Start ()
{
if (isLocalPlayer)
{
GetComponent().enabled = true;
Camera.main.transform.position = this.transform.position - this.transform.forward*10 + this.transform.up*8;
Camera.main.transform.LookAt(this.transform);
Camera.main.transform.parent = this.transform;
}
}
void Update()
{
if (isLocalPlayer)
this.GetComponentInChildren ().text = pname;
}
}
And I want to change this part to not rotate the camera when I rotate the player around :
void Start ()
{
if (isLocalPlayer)
{
GetComponent().enabled = true;
Camera.main.transform.position = this.transform.position - this.transform.forward*10 + this.transform.up*8;
Camera.main.transform.LookAt(this.transform);
Camera.main.transform.parent = this.transform;
}
}
Sorry for my english, i'm quebecois and thank you very much. :)
↧