x


Multiplayer - creating server/client non-authorative with the FPS prefab

I'm trying to create a lan multiplayer game using the FPS prefab as the player.

I can instantiate the prefab on both client and server but the problem is that in each side I'm controlling both prefabs.

Thoughts?

Thanks for any help,

more ▼

asked Mar 09 '10 at 08:17 PM

maveryck21 gravatar image

maveryck21
239 29 32 44

Hello, I dont have an answer, but, have you checked this? http://www.m2h.nl/files/M2H_Networking_Tutorial.pdf

Mar 16 '10 at 11:35 AM naruse
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

If you check out the multiplayer tutorial (the one with the Storm Trooper ) there is a script there called RigidAssign.js.

This makes sure that what you control locally is not also controlled by a network view.

You can make a script, call it FPSPrefabAssign.cs (I prefer C# for scripting) and assign it to the FPSPrefab (the prefab that you instantiate and has attached a NetworkView component).

The only thing you have to write in the FPSPrefabAssign.cs script is:

void OnNetworkInstantiate( NetworkMessageInfo msg )
{

    //get the script that is sent over the network through the NetworkView
    FPSNetworkSynchronizer ns= (FPSNetworkSynchronizer)GetComponent(typeof(FPSNetworkSynchronizer));

    if ( networkView.isMine )
    {
        ns.enabled = false;
    }
    else
    {
        name += "(Remote++)";
        ns.enabled = true;
    }
}

Hope this helps. It is much better if you also take a look at the tutorial, you'll better understand this (possible) solution.

more ▼

answered Oct 19 '10 at 05:08 PM

paulsz gravatar image

paulsz
116 5 7 10

thats says this Assets/Network/Networking Scripts/NewBehaviourScript.cs(10,5): error CS0246: The type or namespace name `FPSNetworkSynchronizer' could not be found. Are you missing a using directive or an assembly reference?

Jan 11 '11 at 11:19 PM Fierce Waffle
(comments are locked)
10|3000 characters needed characters left
Your answer
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:

x1254
x1172
x681

asked: Mar 09 '10 at 08:17 PM

Seen: 3418 times

Last Updated: Mar 09 '10 at 08:17 PM