Skip to content

Instantly share code, notes, and snippets.

View BrentFarris's full-sized avatar
✝️
Some Assembly required

Brent Farris BrentFarris

✝️
Some Assembly required
View GitHub Profile
@BrentFarris
BrentFarris / StopInterpolateOnIndependentNetSync.cs
Created August 27, 2015 09:34
Forge Networking: Stop Interpolate on Independent NetSync
using UnityEngine;
using System.Collections;
using BeardedManStudios.Network;
public class StopInterpolateOnIndependentNetSync : NetworkedMonoBehavior
{
[NetSync(NetSync.Interpolate.False)]
public float number = 0;
@BrentFarris
BrentFarris / HTTPLibrary.cs
Created August 27, 2015 09:34
Forge Networking: HTTP Library
using UnityEngine;
using System.Collections;
using BeardedManStudios.Network;
public class HTTPLibrary : MonoBehaviour
{
private void Update()
{
if (!Input.GetKeyDown(KeyCode.Space))
@BrentFarris
BrentFarris / BanPlayersForTimePeriod.cs
Created August 27, 2015 09:35
Forge Networking: Ban Players For Time Period
using UnityEngine;
using System.Collections;
using BeardedManStudios.Network;
public class BanPlayersForTimePeriod : SimpleNetworkedMonoBehavior
{
protected override void Update()
{
base.Update();
@BrentFarris
BrentFarris / dynamic-gist-embed.html
Last active August 29, 2015 14:13
Gist iFrame With Working Links
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Dynamic Gist Embedding</title>
</head>
<body>
<div id="gistZone"></div>
@BrentFarris
BrentFarris / Forge-Networking-Host.cs
Last active August 29, 2015 14:13
Host a Server With Forge Networking
using UnityEngine;
using BeardedManStudios.Network;
public class StartServer : MonoBehaviour
{
public ushort port = 15937; // Port number
public Networking.TransportationProtocolType protocolType = Networking.TransportationProtocolType.UDP; // Communication method
public int playerCount = 31; // Maximum player count -- excluding this server
private void Start()
@BrentFarris
BrentFarris / Forge-Networking-Client.cs
Last active August 29, 2015 14:13
Connect to a Server With Forge Networking
using UnityEngine;
using BeardedManStudios.Network;
public class StartServer : MonoBehaviour
{
public string host = "127.0.0.1"; // IP address
public ushort port = 15937; // Port number
public Networking.TransportationProtocolType protocolType = Networking.TransportationProtocolType.UDP; // Communication method
private void Start()
@BrentFarris
BrentFarris / Forge-StartGame.cs
Last active August 29, 2015 14:13
Forge Networking Sample: Autostart Scene
using UnityEngine;
using BeardedManStudios.Network;
public class StartGame : MonoBehaviour
{
public string host = "127.0.0.1"; // IP address
public ushort port = 15937; // Port number
public Networking.TransportationProtocolType protocolType = Networking.TransportationProtocolType.UDP; // Communication protocol
public int playerCount = 31; // Maximum player count -- excluding this server
public string sceneName = "Game"; // Scene to load
@BrentFarris
BrentFarris / Forge-Check-Connected.cs
Created January 10, 2015 23:54
Forge Networking Sample: Checking if Connected
if (Networking.Connected)
{
// TODO: Fancy stuff
}
@BrentFarris
BrentFarris / Forge-Register-Connected.cs
Last active August 29, 2015 14:13
Forge Networking Sample: Registering Connected
// Note: 15937 is the port number of the socket you started the connection on
Networking.Sockets[15937].connected += MyMethod;
void MyMethod()
{
Debug.Log("Connection Established");
}
// Or you can in-line if you wish
@BrentFarris
BrentFarris / Forge-Register-Disconnected.cs
Last active August 29, 2015 14:13
Forge Networking Sample: Registering Disconnected
// Note: 15937 is the port number of the socket you started the connection on
Networking.Sockets[15937].disconnected += MyMethod;
void MyMethod()
{
Debug.Log("Connection Closed or Lost");
}
// Or you can in-line if you wish