-
-
Notifications
You must be signed in to change notification settings - Fork 305
Lord Bailey's Guide to Forge Remastered
Greetings fellow developers,
Before we get started I will be expecting that you understand basic C# and how the Unity editor works. You should not look at this as a complete expert level full guide but a helpful leg up to do some common things. Another thing you should note is that I am not presenting myself as a master of Forge so if you know of a better way by all means do that instead, this is just my way.
It is advised to have a backup of your generated files in case if you need to roll back
I will update this guide as I learn so it may feel empty for a time, but will grow as I do.
So Hello World! Let's make a multiplayer game.
if (networkObject.Owner.Disconnected) { networkObject.Destroy(); }
Note: Should be called by all peers and not just the owner.
args.Info.SendingPlayer
NetworkManager.Instance.InstantiatePlayerCube();
Note: You need to setup the object in the NCW (That menu where you can set values) before you try to make a script. So After you make some thing like SuperAwesomePlayer you'll then create a script with SuperAwesomePlayerBehavior in the inheritance with BeardedManStudios.Forge.Networking.Generated; as a using statement. Next drag your model into unity, assign the script to it and make it a prefab. Then go into the bearded man studios prefab folder and find the networkManager prefab, You'll find a slot inside of it if you click on it, Drag and drop your prefab into the SuperAwesomePlayer slot. Esstentally it's a Gameobject Array which I'm sure you know all about. Now if you did everything right it should spawn. @!LordBailey if you need help.
2nd Note: Who ever instantiated the object is considered it's Owner!
` protected override void NetworkStart() { base.NetworkStart();
}
` This should work, just make sure you don't put anything before base.NetworkStart(); I know there is also other ways, But currently I haven't found it. So if you do know a way then please @!LordBailey so I can update this. Sharing is caring :)
if(networkObject.isOwner)
if(networkObject.isServer)
First make sure you have two fields inside of your NCW for that object you made that should be position Vector3 rotation Quaternion
then inside of the Update code you'll want to do the following
` if(!networkObject.isOwner) { transform.position = networkObject.position; transform.rotation = networkObject.rotation; return;
//This says if you're not the owner of the object (The one that spawned it) you'll just update from the network. }
else { networkObject.position = transform.position; networkObject.rotation = transform.rotation;
//This says if you are the owner (Players that spawned this object) you'll set the network values based. }
//After this you can add whatever kind of movement code locally, Note you can also send RPCs to do movement but this is the most simple way that I've found.`
Inside of the NCW under the object you're trying to send an RPC from (SuperAwesomePlayer) you'll need to add a RPC by clicking on that button [RPC].
Give it a name like sayHello
Then click the [+] and set a string in the new slot. The name of this slot doesn't matter at all but you should name it something that will remind you what it's for later.
After this SAVE & COMPILE
Go back to your script for (superAwesomePlayer) you'll see the name of the script has an error. Click on the name of the script inside of the script to the left of the superAwesomePlayerBehavior and then press| CTRL + . |at the same time. Then click the extract method option presented and it will give you a new method.
After this inside of method you can write Debug.Log(args.GetNext()); which will be called when the RPC is sent.
Now inside of Update do the following string hello = "Hello World"); networkObject.SendRPC(RPC_HELLO,Recievers.All,hello);
Run the app and you'll see Hello World being printed a bunch of times.
https://discord.gg/h2HYkye and you can @!LordBailey or @NFMynster
Getting Started
Network Contract Wizard (NCW)
Remote Procedure Calls (RPCs)
Unity Integration
Basic Network Samples
Scene Navigation
Master Server
Netcoding Design Patterns
Troubleshooting
Miscellaneous
-
Connection Cycle Events
-
Rewinding
-
Network Logging
-
Working with Multiple Sockets
-
Modify Master and Standalone servers
-
NAT Hole Punching
-
UDP LAN Discovery
-
Offline Mode
-
Ping Pong
-
Lobby System
-
Upgrading Forge Remastered to Develop branch or different version
-
Forge Networking Classic to Remastered Migration Guide
-
Script to easily use Forge Networking from sources
-
Run Two Unity Instances with Shared Assets for Easiest Dedicated Client Workflow