- Home /
Question by
jakeflaze3859 · Dec 02, 2014 at 11:47 PM ·
c#multiplayerphotoncontrol
Help with basic photon cloud multiplayer control.
I wrote a basic c# script to move a rigidbody back and forth. When I start the built game I can't control my character. When I start the built game again, so that two copies of the game are running at the same time, I can control both characters, but the control is reversed. Basically player 1 controls player 2 and player 2 controls player 1. Here's my script in case anyone can figure out what I'm doing wrong.
using System;
using ExitGames.Client.Photon;
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(PhotonView))]
public class NetworkKeyMovement : Photon.MonoBehaviour {
void Update() {
if (this.photonView.isMine&&Input.GetKey("up"))
rigidbody.velocity = new Vector3(0, 0, 8);
if (this.photonView.isMine&&Input.GetKey("down"))
rigidbody.velocity = new Vector3(0, 0, -8);
}
}
Comment
That script doesn't look like the cause for your issues. Try this on another prefab which you instantiate in a room.
Your answer
Follow this Question
Related Questions
How to make camera position relative to a specific target. 1 Answer
Photon Combat script does not work 0 Answers
PUN Join/Create menu tutorials 0 Answers
Unity3D Photon movement synchronization 0 Answers