0

Im using UNET to make a multiplayer FPS.I have a player prefab for which the network identity script has an attribute local player authority that i have enabled.

My PlayerMotor Script is as below:

using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class PlayerMotor : MonoBehaviour {

public static PlayerMotor instance;

private Vector3 velocity, rotation, cameraRotation;
private Rigidbody rb;
[SerializeField]
private Camera playerCamera;

private void Start(){

    if (instance == null){
        instance = this;
    }

    rb = GetComponent<Rigidbody>();
}

private void FixedUpdate(){

    //Perform Movement Using Vector Property
    Move();
    //Perform Player Rotation Using rotation Property - (Y-Axis)
    //Perform Camera Rotation Using cameraRotation Property - (X-Axis)
    Rotate();

}

private void Move(){
    if (velocity != Vector3.zero){
        rb.MovePosition(transform.position + (velocity * Time.fixedDeltaTime));
    }
}

private void Rotate(){
    rb.MoveRotation(rb.rotation * Quaternion.Euler(rotation));

    if(playerCamera != null){
        playerCamera.transform.Rotate(-cameraRotation);
    }
}

public void UpdateVelocity(Vector3 _velocity){
    velocity = _velocity;
}

public void UpdateRotation(Vector3 _rotation){
    rotation = _rotation;
}

public void UpdateCameraRotation(Vector3 _cameraRotation){
    cameraRotation = _cameraRotation;
}
}

Furthermore, the host works fine and all movement is communicated over the network. I can see that on the client side the host transform updating.

Player Prefab Network Components Player prefab network components

Network Manager Configuration enter image description here

I have seemed to tried everything, i do not get any warnings. Plus i disable the camera, audio listener ,and player controller for all non local players.

So i'm pretty much blank on how to proceed.

1 Answers1

0

My guess would be that you need to move the player on the server to have of syncronized. Try making move and rotate commands.

Marek Legris
  • 113
  • 1
  • 9