- Home /
Mirror Network transform not working
I'm doing a server-client and a client connection using mirror. I want both the server-client and client to see the same airplane in the scene. The airplane prefab gets instantiated on the client but the movement of the prefab is only shown on the server-client. When I use the editor as a client and I look at the scene I see a Gizmos sphere that moves to the location I need it to move.
- The prefab has a Network Identity, Network Transform.
In the Network Manager gameobject I have Network Manager, Kcp Transport, and Network Manager Hud.
- I added the enemy prefabs to the registered Spawnable prefabs.
Added the NetworkStartPosition to my launch point object.
What could I be doing wrong?
Answer by AnonymousForest · Apr 01, 2021 at 11:49 PM
You are probably going to have to write code to sync the position.
So in Void Update() you will have something like
"cmdSyncPlanePosition"
Then that method would look like
[Command]
private void cmdSyncPlanePosition(Vector3 currentPosition, Quaternion currentRotation)
{
ServerSyncPlanePosition(currentPosition, currentRotation);
}
Then the last method would look like
[ClientRpc]
private void ServerSyncPlayer(Vector3 currentPosition, Quaternion currentRotation)
{
if(!isLocalPlayer)
{
transform.position = currentPosition;
transform.rotation = currentRotation;
}
}
That would sync the plane position on every update or whenver you call them basically. If that doesn't work it might be an issue with animation or something
Doesnt the network transform component takes cares of the movements?