- Home /
Multiplayer camera please help
Hi to all, i'm italian sorry for bad english, i am trying to make a multiplayer game with unity, i follow this guide and i have added 2 cams for each cube player, with network and this script:
#pragma strict
var cam1 : Camera;
function Start (){
if(networkView.isMine){
cam1.enabled = true;
}
else{
cam1.enabled = false;
}
}
i have tried also to make 2 player prefabs, one for each player,but nothing, when i connect i see my friend's camera and he see the mine... Please help, what i have to do?
Answer by nazia08 · Apr 04, 2014 at 10:01 AM
My camera buttons aren't working because we had this weird mechanism for the arrow buttons and it broke. And every time we let out camera get out of battery it tells us to retype the date - which we can't do because the arrow buttons aren't working.
Answer by lll4louis · Jun 30, 2018 at 08:30 AM
I had this problem before, and soon I find out that you should not put the camera into the Player.
and in this camera, I make two script for it
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace S3
{
public class CameraFollow : MonoBehaviour
{
public Transform playerTransform;
public int depth = 0;
// Update is called once per frame
void Update()
{
if (playerTransform != null)
{
transform.position = playerTransform.position + new Vector3(0, 0, depth);
}
}
public void setTarget(Transform target)
{
playerTransform = target;
}
}
}
and the next script
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
namespace S3
{
public class CameraController : NetworkBehaviour
{
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
float x = Input.GetAxis("Horizontal") * Time.deltaTime * 150.0f;
float z = Input.GetAxis("Vertical") * Time.deltaTime * 3.0f;
transform.Rotate(0, x, 0);
transform.Translate(0, 0, z);
}
}
}
so, it will become a FPS game, hope it works.
The following is a useful tutorial: https://unity3d.com/learn/tutorials/s/multiplayer-networking
Your answer
Follow this Question
Related Questions
How do you use a camera from another scene on your skybox? 1 Answer
My Camera won't activate trough script 1 Answer
Camera Board Game - Multiplayer,Multiplayer camera - best practice 1 Answer
Many Audio Listeners to multiplayer?? How? 1 Answer
How to have player camera Render enemy but not itself with same tag and camera clipping mask? 0 Answers