- Home /
Question by
Phoenix3666 · Jul 18, 2018 at 03:00 AM ·
c#multiplayernoobnetworkplayer
How do I make this script only apply to the local player
Hi, I'm having trouble making this script apply to only the local player, whenever I move my mouse both players move their heads, everything else works fine,
public class CameraFPC : NetworkBehaviour {
Vector2 mouselook;
Vector2 smoothV;
public float sensitivity = 5.0f;
public float smoothing = 2.0f;
public GameObject frickinwork;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (!isLocalPlayer)//trying to make it ony work for local player
{
return;
}
var md= new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
//tracks movement
md = Vector2.Scale (md, new Vector2 (sensitivity* smoothing, sensitivity * smoothing));
smoothV.x = Mathf.Lerp(smoothV.x, md.x, 1f / smoothing);
smoothV.y = Mathf.Lerp (smoothV.y, md.y, 1f / smoothing);
mouselook += smoothV;
mouselook.y = Mathf.Clamp (mouselook.y, -90, 90);
frickinwork.transform.localRotation = Quaternion.AngleAxis (-mouselook.y, Vector3.right);
transform.localRotation = Quaternion.AngleAxis (mouselook.x, Vector3.up);
}
}
I tried to make it only affect the local player by doing
if (!islocalplayer){
return;
} thanks for any help!
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Multiplayer frendly weapon select screen 0 Answers