I am trying out UNET ( Unity Multiplayer Service ) and I am building a space invaders like game but with two players at each side of the screen shooting at each other.

I want the local player to always be at the bottom of the screen and see the enemy at the top.

I tried checking isLocalPlayer and isServer and only if both are false -> this means it's the enemy player and change his transform and rotation to be facing downwards and be at the top. But this brings unexpected behavior like spawning the bullets on the original position.

  • \$\begingroup\$ This will be difficult for us to debug unless we can see how you are spawning the bullets and other content which is behaving badly. You might however be able to play with one character "truly" on top in all copies of the scene, and merely rotate the camera or canvas for one of the players so they appear on the desired part of the screen. \$\endgroup\$
    – DMGregory
    Nov 6, 2015 at 18:16

1 Answer 1


You'll want to take a different approach for this. Rather than trying to change the players' positions based on who the local player is, move/flip the camera to orient around the local player. Here's one way you could do this:

Create a component to attach to your camera:

using UnityEngine;
using System.Collections;

public class PlayerCamera : MonoBehaviour {
    [Tooltip("How far to offset the camera from the local player's starting position")]
    Vector3 offset;

    public void OrientOn(Transform target) {
        transform.position = target.position + offset;
        transform.rotation = target.rotation;

Then add something like this inside your player's NetworkBehaviour:

    PlayerCamera playerCam;

    public override void OnStartLocalPlayer() {
        // This will only be called on the local player

You'll want to tweak offset to suit your purposes, and may want to make some changes, but this should make sure the camera always starts oriented correctly in relation to the local player.

As a side note, you'll want to make sure your player movement is all being done with localPosition instead of position. This will make movement work correctly independent of the player's actual facing.

I'd recommend giving the NetworkBehaviour scripting page a read. It's a great starting point if you want to figure out the guts of UNET. The Network callbacks and server/client functions sections in particular are quite useful.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .