hi, the isLocalPlayer check returns false ONLY for the client in this script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
public class movement : NetworkBehaviour
{
public CharacterController playerController;
public float speed = 12f;
public float gravity = -9.81f;
public float jumpHeight = 5f;
public Animation walking;
Vector3 velocity;
Vector3 startposition;
public AudioSource stone;
public AudioSource metal;
public AudioSource carpet;
public TerrainCollider terrainCheck;
public RaycastHit hit;
public GameObject camera;
int timer;
void Start()
{
}
// Update is called once per frame
void FixedUpdate()
{
if (this.isLocalPlayer)
{
camera.active = true;
Debug.Log("yay finally");
timer++;
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = transform.right * x + transform.forward * z;
playerController.Move(move * speed * Time.deltaTime);
velocity.y -= gravity * Time.deltaTime;
if (playerController.velocity.magnitude > 3f)
{
walking.Play();
}
if (Physics.Raycast(transform.position, Vector3.down, out hit, 1.7f))
{
if (playerController.velocity.magnitude > 3f && hit.collider.gameObject.tag == "stone" && stone.isPlaying == false)
{
stone.volume = Random.Range(0.8f, 1.1f);
stone.pitch = Random.Range(0.8f, 1.1f);
stone.Play();
}
else if (playerController.velocity.magnitude > 3f && hit.collider.gameObject.tag == "metal" && timer % 13 == 0)
{
metal.volume = Random.Range(0.8f, 1.1f);
metal.pitch = Random.Range(0.8f, 1.1f);
metal.Play();
}
else if (playerController.velocity.magnitude > 3f && hit.collider.gameObject.tag == "carpet" && carpet.isPlaying == false)
{
carpet.volume = Random.Range(0.8f, 1.1f);
carpet.pitch = Random.Range(0.8f, 1.1f);
carpet.Play();
}
}
playerController.Move(velocity * Time.deltaTime);
}
if (!isLocalPlayer)
{
camera.active = false;
enabled = false;
}
}
}
and i dont understand why. i am still new to this entire networking thing and to coding itself so its probably a stupid error, but id like help. thanks in advance!