- Home /
 
Problem is not reproducible or outdated
object won't move with script or when I change the values in the inspector during play mode
Script was working for a while but I did things and then it stopped working. The object is not static. It doesn't show the values changing in the inspector Also it doesn't move when I change the values. Help Also I have tried other movement scripts, still won't move the player.
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine.Networking;
 using UnityEngine;
 
 public class Move : NetworkBehaviour {
     public float speed = 1;
     // Use this for initialization
     void Start () {
         
     }
     
     // Update is called once per frame
     void Update () {
          if(!isLocalPlayer){
             return;
         }
         //Move Up
         if(Input.GetKey(KeyCode.W)){
             Debug.Log("moving");
             transform.Translate(0,speed*Time.deltaTime,0);
         }
         //Move Down
         if(Input.GetKey(KeyCode.S)){
             Debug.Log("moving");
             transform.Translate(0,-speed*Time.deltaTime,0);
         }
         //Move Left
         if(Input.GetKey(KeyCode.A)){
             Debug.Log("moving");
             transform.Translate(-speed*Time.deltaTime,0,0);
         }
         //Move Right
         if(Input.GetKey(KeyCode.D)){
             Debug.Log("moving");
             transform.Translate(speed*Time.deltaTime,0,0);
         }
 
     }
 }
 
 
               Thank you!
Answer by FallingRocketGames · Nov 01, 2017 at 11:01 PM
I believe you need to change the if to else if in the next statements, second I don't know much of the code you're trying to make but seems to be for an online player for which I don't see any instruction.
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/if-else there's a guide to the if statement in c#
             if(!isLocalPlayer){
                 return;
              } else {//INSTRUCTIONS FOR LOCAL PLAYER}
 
               Also check if the script is attached to any of your game objects
I'm pretty(not 100%) sure that it shouldn't matter if i said else or if because if its not the local player it would get out of update and return. Also changing it to else didn't help:(
Answer by pro-costa · Nov 01, 2017 at 11:22 PM
I figured it out I had a network identity on a child object, and i'm pretty sure deleting it solved it. IDK why but its fixed so I can sleep now