Search Unity

Why does my move script not work in network????

Discussion in 'Multiplayer' started by H00D3DM4N2787, Oct 18, 2014.

  1. H00D3DM4N2787

    H00D3DM4N2787

    Joined:
    Aug 6, 2014
    Posts:
    27
    ive set it to originally be disabled
    and a script that enables it on instantiate
    and i use the photoninstantiate

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class MoveJoe : MonoBehaviour {
    5.  
    6.     public float jump1 = 10;
    7.     public float turnspeed = 100;
    8.     public float walkspeed = 15;
    9.     public float runMultiplier = 2;
    10.     public float midairmove = 20;
    11.     public float gravity = 25;
    12.     public float airtime = 0;
    13.     public float jumptime = 1;
    14.     public float fall = 1;
    15.  
    16.     public CollisionFlags collideflags;
    17.  
    18.     public CameraControls cam;
    19.    
    20.     private Vector3 movedirection;
    21.     private CharacterController ctrl;
    22.     private Transform mytransform;
    23.  
    24.     void Start () {
    25.  
    26.         cam = GetComponent<CameraControls> ();
    27.         mytransform = transform;
    28.         ctrl = GetComponent<CharacterController> ();
    29.         movedirection = Vector3.zero;
    30.         Debug.Log ("DONE :)");
    31.         }
    32.  
    33.     // Update is called once per frame
    34.     void Update () {
    35.  
    36.         if (Mathf.Abs (Input.GetAxis ("Horizontal")) > 0) {
    37.             mytransform.Rotate (0, Input.GetAxis ("Horizontal") * Time.deltaTime * cam.xspeed, 0);
    38.         }  
    39.  
    40.         if (ctrl.isGrounded) {
    41.  
    42.             movedirection = new Vector3 ( 0, 0, 0);
    43.  
    44.             Walk ();
    45.  
    46.             Strafe ();
    47.  
    48.             airtime = 0;
    49.  
    50.         if (Input.GetButton ("Jump")) {
    51.             movedirection.y += jump1;
    52.            
    53.             }
    54.         }
    55.         else {
    56.  
    57.             if ((collideflags & CollisionFlags.CollidedBelow) == 0) {
    58.                 airtime += Time.deltaTime;
    59.  
    60.                 if (airtime > fall) {
    61.                     Fall ();
    62.                 }
    63.                
    64.             }
    65.         }
    66.         ctrl.Move (movedirection * Time.deltaTime);
    67. }
    68.    
    69.     void Walk () {
    70.  
    71.         if (Mathf.Abs (Input.GetAxis ("Vertical")) > 0) {
    72.             if(Input.GetButton("Sprint")) {
    73.                 ctrl.Move(mytransform.TransformDirection(Vector3.forward) * Input.GetAxis("Vertical") * walkspeed * runMultiplier * Time.deltaTime);
    74.                 }
    75.             else {
    76.                 ctrl.Move(mytransform.TransformDirection(Vector3.forward) * Input.GetAxis("Vertical") * walkspeed * Time.deltaTime);
    77.                 }
    78.             }
    79.         }
    80.  
    81.     void Strafe () {
    82.  
    83.             if (Mathf.Abs (Input.GetAxis ("Horizontal")) > 0) {
    84.                 ctrl.Move (mytransform.TransformDirection (Vector3.right) * Input.GetAxis ("Horizontal") * walkspeed * Time.deltaTime);      
    85.             }
    86.         }
    87.  
    88.     public void Fall () {
    89.        
    90.     }
    91. }
    this script works fine before i used network
    now he just doesnt move AT ALL
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    Check if the script that enables it OnInstantiate is really enabling this script on instantiate.