x


Multiplayer - one player is controlling everyone

I'm using Networking example to create MMO game. And when I connect in 2 places (Unity and Build) everything works fine. Except the thing that when I'll move my player in Unity, me and the 2nd player are moving in the same time. How can I fix this? C# movement script (It's actually from MMO movement from Assets store):

using UnityEngine;
using UnityEditor;
using System.Collections;

[CustomEditor (typeof (ThirdPersonController))]
public class ThirdPersonControllerEditor : PropertyEditor
{
    private SerializedProperty targetProperty;
    private SerializedProperty speedProperty;
    private SerializedProperty walkSpeedDownscaleProperty;
    private SerializedProperty turnSpeedProperty;
    private SerializedProperty mouseTurnSpeedProperty;
    private SerializedProperty jumpSpeedProperty;
    private SerializedProperty groundLayersProperty;
    private SerializedProperty groundedCheckOffsetProperty;
    private SerializedProperty showGizmosProperty;
    private SerializedProperty requireLockProperty;
    private SerializedProperty controlLockProperty;


    private const float rotationSpeedHandleScale = 20.0f;
       // Scales the visualization of the rotation speed handles. Reduce if you're dealing with larger rotation speeds.


    protected override void Initialize ()
    {
       targetProperty =           serializedObject.FindProperty ("target");
       speedProperty =           serializedObject.FindProperty ("speed");
       walkSpeedDownscaleProperty =  serializedObject.FindProperty ("walkSpeedDownscale");
       turnSpeedProperty =        serializedObject.FindProperty ("turnSpeed");
       mouseTurnSpeedProperty =      serializedObject.FindProperty ("mouseTurnSpeed");
       jumpSpeedProperty =        serializedObject.FindProperty ("jumpSpeed");
       groundLayersProperty =       serializedObject.FindProperty ("groundLayers");
       groundedCheckOffsetProperty =     serializedObject.FindProperty ("groundedCheckOffset");
       showGizmosProperty =         serializedObject.FindProperty ("showGizmos");
       requireLockProperty =          serializedObject.FindProperty ("requireLock");
       controlLockProperty =          serializedObject.FindProperty ("controlLock");
    }


    public override void OnInspectorGUI ()
    {
       BeginEdit ();
         BeginSection ("Target character");
          PropertyField ("Rigidbody", targetProperty);
         EndSection ();

         BeginSection ("Speed");
          PropertyField ("Movement", speedProperty);
          PropertyField ("Walk downscale", walkSpeedDownscaleProperty);
          PropertyField ("Turn", turnSpeedProperty);
          PropertyField ("Mouse turn", mouseTurnSpeedProperty);
          PropertyField ("Jump", jumpSpeedProperty);
         EndSection ();

         BeginSection ("Grounding check");
          PropertyField ("Layers", groundLayersProperty);
          Comment ("This should include anything that the character can land on. Make sure that any part of the character is not in any of these layers.");
          PropertyField ("Offset", groundedCheckOffsetProperty);
         EndSection ();

         BeginSection ("Mouse control");
          PropertyField ("Require lock", requireLockProperty);
          PropertyField ("Control lock", controlLockProperty);
         EndSection ();

         PropertyField ("Show gizmos", showGizmosProperty);

         EndSection ();

         WideComment ("This component uses more input than is included in the default input setup:\n\n - An extra axis named \"Sidestep\" - a straight copy of the \"Horizontal\" input axis - mapped to Q (negative) and E (positive).\n\n - An extra button named \"ToggleWalk\" - same setup as the \"Jump\" button, by default mapped to \"+\" (positive).");
       EndEdit ();
    }


    public override bool RenderSceneHandles
    {
       get
       {
         BeginEdit ();
         return showGizmosProperty.boolValue;
       }
    }


    public override Color SceneHandlesColor
    {
       get
       {
         return Color.red;
       }
    }


    protected override void DoSceneGUI ()
    {
       BeginEdit ();
         speedProperty.floatValue = Handles.RadiusHandle (TargetTransform.rotation, TargetTransform.position, speedProperty.floatValue);
          // Do a wire sphere handle for modifying the speed as a radius

         float visualizedRotationAngle = turnSpeedProperty.floatValue * rotationSpeedHandleScale;
          // Scaling up the angle used in visualization of the rotation speed as we're dealing with low values per default

         DrawThickWireArc (TargetTransform, visualizedRotationAngle, speedProperty.floatValue, 20, 0.005f);
          // Draw the indication of the rotation speed as an angle segment of the planar circle, indicating speed

         float change = AngularSlider (
          TargetTransform,
          visualizedRotationAngle,
          speedProperty.floatValue,
          20.0f * 0.005f * HandleUtility.GetHandleSize (TargetTransform.position)
         ) - visualizedRotationAngle;
          // Do the slider handle, allowing us to modify the rotation speed from the scene view

         if (visualizedRotationAngle + change < 360.0f)
         // Don't allow dragging over 360 degrees. This check is needed since we're scaling up the visual representation of the angle.
         {
          turnSpeedProperty.floatValue = Mathf.Clamp (turnSpeedProperty.floatValue + change / rotationSpeedHandleScale, 0.0f, 360.0f);
         }
         else
         // Clamp to 360
         {
          turnSpeedProperty.floatValue = 360.0f / rotationSpeedHandleScale;
         }
       EndEdit ();
    }
}
more ▼

asked Aug 25 '12 at 02:13 PM

Different gravatar image

Different
28 2 4 7

Also, don't tell me "Search networkView.isMine", I know about it. Just how I can edit this script to make it work.

Aug 25 '12 at 02:22 PM Different

you'd post a editor for ThirdPersonController that is not used in runtime at all, it's just a editor class for unity editor only. so you needn't edit this script at all.

Aug 26 '12 at 08:32 PM ScroodgeM

for TPC that including the unity standard packages, Assets / Standard Assets / Character Controllers / Sources / Scripts / ThirdPersonController.js

Aug 27 '12 at 08:37 AM ScroodgeM

what do you want to know about it? this class used to draw inspector in unity editor when you select TPC in project.

Aug 27 '12 at 09:01 AM ScroodgeM

So since your question asked something completely different what you're asking here in the comments, i suggest to think about your question beforehand and then post it. Can you now please tell us if the question has anything to do with the Custom inspector you've posted here, or with the issue you described in your text?

Aug 27 '12 at 10:21 AM Bunny83
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2058
x1425
x713
x7

asked: Aug 25 '12 at 02:13 PM

Seen: 458 times

Last Updated: Aug 27 '12 at 10:21 AM