Question by
osybear · Apr 21, 2017 at 02:30 PM ·
networkingmultiplayer
Problem with UNET using NetworkManagerHUD
So I created a very basic testing project for UNET to understand how it works. Here is the Player Controller script. When I connected via LAN 2 players. The second Player doesnt sync with the first one and vice versa. But the first player that created the 'match' syncs with the second player and vice versa.
Then I decided to do it with MM and the same outcome applies.
Can anyone help me with this?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class Player : NetworkBehaviour {
public float speed = 6.0F;
public float jumpSpeed = 8.0F;
public float gravity = 20.0F;
private Vector3 moveDirection = Vector3.zero;
void Update()
{
if(!isLocalPlayer)
{
return;
}
CharacterController controller = GetComponent<CharacterController>();
if (controller.isGrounded)
{
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if (Input.GetButton("Jump"))
moveDirection.y = jumpSpeed;
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
}
Comment
Your answer
Follow this Question
Related Questions
Android multiplayer using WiFi 5 Answers
Unity Networking 1 Answer
UNET | How to use network messages? 1 Answer
Self hosted Unity Multiplayer alternative? 2 Answers
Using Transform Component and selfmade interface in an Network Command ? 0 Answers