Code Monkey home page Code Monkey logo

hft-unity3d's Introduction

HappyFunTimes-Unity3D

DEPECATED

I'm deprecating happyfuntimes. I'll keep the rendevous server running for a while longer but I think it's unfortunately time to mostly depreciate this project

i'll consider accepting PRs still if you want to fix something but otherwise just fork it if you want to keep using it

Issues

There are a few major issues on why

  1. device orientation is no longer usable

    Both Safari and Chrome have made getting device orientation require HTTPS which is something HFT can't provide at the moment. It would require $$$$$$$. If a end-user friendly solution comes up maybe I'll revisit

  2. Browsers break stuff

    Every year or so a browser changes something or breaks something. Over the course of HTF browser broke fullscreen support, audio support, touch support, orientation support, and other things. It's no fun to keep up on that

  3. OSes break stuff

    For whatever reason networking that work before stops working. HFT has to do some things to find out all the ways your phone might connect to the game and that stuff seems to break every 2 years or so

  4. Offline Support breaks

    Using HFT without internet breaks every few year and will likely eventually be unfixable. Both iOS and Android ping Apple and Google respectively when you connect to WiFi to check if you're acutally on the internet. HFT tries to send them fake data so they believe they are, otherwise they'll stop using the WiFi and switch to mobile.

    How they do this changes every few years so HFT has to figure out how to change its faking. It is within Apple and Google's power to make this faking impossible and I supsect they might at sometime which is scary because if they do then there is no solution (well, short of acutally providing internet access)

  5. More browser features require HTTPS

    This is really #1 and #2 repeated but more and more browser features require HTTPS and as it says above there is no way for hft to provide HTTPS at the moment.

Good news

If you don't need device orientation and you have no need for offline mode/installation mode then HFT still works. Write your own controllers to keep up to date with the latest changes in the browsers.

Bad news

I don't really have time to keep it running.

HappyFunTimes is a system for making game with 10-100+ players. Players connect using their phones. Nothing needs to be installed on there phone. They can join immediately.

The controllers are made with HTML5 so you can customize them all you want. There is a simple gamepad controller included so you can get started without making a custom controller.

Install

Clear here to get it from the unity asset store.

Docs

Some more docs can be found here.

You can get this from the Unity Asset Store or you can download it directly here

Changelist

See here

Cloning

This repo uses git lfs. To clone install git lfs then

git lfs clone https://github.com/greggman/hft-unity3d.git

Building

If you want to use this repo directly you should be aware of a few requirements

hft.js and hft.min.hs

These are generated from files in src/hft using webpack.

Prerequisites

make sure you have node.js installed and type

cd path/to/repo
npm install

This will download the required libraries and tools

building

cd path/to/repo
./src/build

Note I have no made build scripts for windows. Feel free to submit a PR.

sample-ui

The sample-ui is also in src/hft and is also generated with webpack

Building

Follow the instructions for hft.js above

The OSX installation mode server

To run installation mode requires administrator priviledges because it needs ports 80 and 53. To achieve this on OSX we generate a separate web server program that is only used in installation mode. This program is in hft-server.

Prerequisites

Install the Xamarin Platform

Building

cd path/to/repo
./hft-server/build

Note I have no made build scripts for windows. Feel free to submit a PR.

Dev Notes

macOS

For whatever reason I can't seem to get the output of the macOS external server to deliver debug messages. To test that you can put a return; at the top of HFTManager.StartExternalServer. Then run the external server manually something like this

sudo  ~/Library/Application\ Support/Greggman/hft-unity3d/hft-server --hft-args="{\"debug\":\"*\",\"dns\":true,\"installationMode\":true,\"controllerFilename\":\"controllers/gamepad/controller.html\"}"

hft-unity3d's People

Contributors

greggman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hft-unity3d's Issues

Mobile device cannot find games when games are running in editor

  • Unity 5.50f3, Windows 10.
  • This happens for sample game scene as well (2DPlatformScene)
  • The localhost:18679 works correctly. So I guess it might be some issue related to the network?
  • There's no console log.
  • I followed the instructions from HappyFunTimes-1.x-to-2.x-Migration-README.txt
  • The following is my current network ipconfig. Let me know more info is needed.
  • Thank you so much for this awesome project and your kindness and patience.
Windows IP Configuration


Ethernet adapter Ethernet:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Wireless LAN adapter Local Area Connection* 3:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Ethernet adapter VMware Network Adapter VMnet1:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::a1d6:83d6:bc25:39ac%12
   IPv4 Address. . . . . . . . . . . : 192.168.107.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

Ethernet adapter VMware Network Adapter VMnet8:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::dca:ee84:3de5:55a%24
   IPv4 Address. . . . . . . . . . . : 192.168.58.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

Wireless LAN adapter Wi-Fi:

   Connection-specific DNS Suffix  . : hsd1.pa.comcast.net
   IPv6 Address. . . . . . . . . . . : 2603:301d:1004:6000:7543:3f06:6190:b8f
   Temporary IPv6 Address. . . . . . : 2603:301d:1004:6000:39e3:f3be:9f96:4b81
   Link-local IPv6 Address . . . . . : fe80::7543:3f06:6190:b8f%23
   IPv4 Address. . . . . . . . . . . : 10.1.10.162
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : fe80::48f7:c0ff:fec5:507e%23
                                       10.1.10.1

Tunnel adapter isatap.hsd1.pa.comcast.net:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . : hsd1.pa.comcast.net

Tunnel adapter Local Area Connection* 2:

   Connection-specific DNS Suffix  . :
   IPv6 Address. . . . . . . . . . . : 2001:0:4137:9e76:28b8:2f38:f5fe:f55d
   Link-local IPv6 Address . . . . . : fe80::28b8:2f38:f5fe:f55d%3
   Default Gateway . . . . . . . . . :

Tunnel adapter isatap.{4886F912-0202-4FBF-BC8D-6FF720D36B4E}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Tunnel adapter isatap.{CEEA63F6-FB5A-4C93-8092-C157C2C1692D}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Upgrading from 1.x to 2.x

You can download it here

Please BACKUP YOUR WORK. Copy your entire project to a new folder and try this in the new folder

Steps

  1. Close Unity
  2. Delete Assets/Plugins/HFTRunner.cs, Assets/Plugins/HappyFunTimes.dll, and Assets/Plugins/Editor/HappyFunTimesEditor.dll
  3. Download the new plugin zip file
  4. Install everything to your project EXCEPT files you changed. For example if you have a custom Assets/WebPlayerTemplates/HappyFunTimes/controller.html don't install over that.
  5. Now open the project in Unity. You were probably using the PlayerSpawner or PlayerConnector script on one of your objects. (in the samples that's usually on an object called LevelManager). That script is probably missing now so reconnect it. Click the circle next to "Missing Script" and select PlayerSpawner or PlayerConnector, which ever one you were using before.
  6. Rename Assets/WebPlayerTemplates/HappyFunTimes to Assets/WebPlayerTemplates/HappyFunTimes2. Make sure Unity is the front app. Then rename it back to Assets/WebPlayerTemplates/HappyFunTimes (this is because the new happyfuntimes has to copy files but it only copies new or modified files. Since your files already exist it can't tell. This rename makes it appear all the files are new).
  7. Go to your PlayerSpawner or PlayerConnector. Under HappyFunTimes.Options put in the path to your controller.html The path is relative to Assets/WebPlayerTemplates/HappyFunTimes. If you were using the gamepad controller set the path to controllers/gamepad/controller.html
  8. If you have a custom controller see below

Things to note:

  • No need to run HappyFunTimes any more
  • Installation mode can be run from inside the editor or from your exported game with a command line switch
  • Just build using the regular Unity build process. Publish on itch.io or whereever you want. (please tag with happyfuntimes
  • No more crazy weird HTML or CSS. You're in complete control. The only file you absolutely must include is /hft/hft.js (or it minimized version) /hft/hft-min.js Everything else is optional and up to you.

Fixing up custom controllers

If you had a custom controller.js or controller.html you'll need to do some editing. Look at one of the other controller.html files in Assets/WebPlayerTemplates/HappyFunTimes/controllers/.... Copy everything from the top of the file to the line

<div id="hft-content">

into the top of your controller.html. Then copy everything from

<div id="hft-menu"><img src="/hft/assets/gear-icon.svg"></div>

to the end to the bottom of your controller.html file.

Similarly compare your controller.js to one of the new controller.js files

The old structure looked like

requirejs([
   ....
  ], function(
   ...
  ) {
     .. lots of code .. 
});

The new structure removes everything except

    .. lots of code ..

And adds a few things.

At the top of controller.js the samples get a bunch of global variables like this

var commonUI = window.sampleUI.commonUI;
var input = window.sampleUI.input;
var misc = window.sampleUI.misc;
var mobileHacks = window.sampleUI.mobileHacks;
var strings = window.sampleUI.strings;
var touch = window.sampleUI.touch;

Make sure those variables match your code. For example maybe you used upper case names like

var CommonUI = window.sampleUI.commonUI;
var Input = window.sampleUI.input;
var Misc = window.sampleUI.misc;
var MobileHacks = window.sampleUI.mobileHacks;
var Strings = window.sampleUI.strings;
var Touch = window.sampleUI.touch;

Look for your line

g_client = new GameClient();

And change it to

g_client = new hft.GameClient();

If your code was using client or some other variable keep the variable the same name, the important part is to change GameClient to hft.GameClient

Look for a line like this

commonUI.setupStandardControllerUI(g_client, globals);

Add these two lines after

commonUI.askForNameOnce();  // ask for the user's name if they haven't set one
commonUI.showMenu(true);   // show the gear menu

Make sure commonUI's case matches your's. If you used CommonUI with an uppercase C then that instead. NOTE if you don't want the user to be asked for a name or you don't want the gear menu just leave those lines out.

Note if you don't want the user to be asked for their name or your don't want to show the gear menu you can leave one or both of those lines out.

SocketException error when running project in Unity

Hi! I have two machines on my home network - a desktop and a laptop, both running Windows 10 64bit. When I run the HFT Unity project on the desktop (which has a wired connection to the router), everything runs great - I can connect to the server and join the game from my mobile and the laptop (either by going to happyfuntimes.net or by directly specifying the IP address of the desktop which, to be honest, I prefer)

But when I try to run the project on the laptop (which has a Wi-Fi connection to the router), I get the following error in the console:

SocketException: An address incompatible with the requested protocol was used.

System.Net.Sockets.Socket..ctor (AddressFamily family, SocketType type, ProtocolType proto)
WebSocketSharp.Net.EndPointListener..ctor (System.Net.IPAddress address, Int32 port, Boolean secure, System.String certificateFolderPath, WebSocketSharp.Net.ServerSslConfiguration sslConfig, Boolean reuseAddress)
WebSocketSharp.Net.EndPointManager.getEndPointListener (System.Net.IPAddress address, Int32 port, Boolean secure, WebSocketSharp.Net.HttpListener listener)
WebSocketSharp.Net.EndPointManager.addPrefix (System.String uriPrefix, WebSocketSharp.Net.HttpListener listener)
WebSocketSharp.Net.EndPointManager.AddListener (WebSocketSharp.Net.HttpListener listener)

The game runs, but no clients can connect. From preliminary Googling (e.g. http://stackoverflow.com/questions/24870277/an-address-incompatible-with-the-requested-protocol-was-used) it seems like this might be related to IP4/IP6 addressing -but I've had a quick poke through the HFT code and it looks like it should adapt correctly for either. I've tried disabling IP4/IP6 individually on the network adapter but no difference :)

Android installation mode not redirecting

game: Windows 10, Unity 5.3.5f1, HFT 2.0.5, local ip 10.0.0.1
controller: Project Tango Tablet, Android 4.4.2, Chrome 51.0.2704.81

Running the sample 2DPlatformer scene.
Tablet gets a "sign into wifi" notification. Tapping it opens chrome with an attempt to download "http://10.0.0.1/generate_204" which is a zero byte file.
If I manually navigate to 10.0.0.1 after that, it loads the controller.

.htaccess like functionality?

I am attempting to use Angular with HappyFunTimes, but the URL routing is giving me some issues.

Normally I would just rewrite it with .htaccess, but I don't think it knows what it is.

I have also been trying to get it to work just at the root of the server, but I get an infinite redirect loop and its very confusing and I'm not sure what to try here.

Connecting to game via IPv6 not working

I'm running my game in installation mode on a dedicated WLAN. When connecting to the game with an apple device via the captive portal, Safari shows the name input, but reloads the page every second, it also creates no player.
It behaves the same when trying to connect with the same IPv6 address, used by the captive portal, with my android smart phone on Chrome.
The used address seems to be an IPv4-mapped IPv6 address: [0000:0000:0000:0000:0000:ffff:c0a8:0001].

When connecting with the IPv4 address directly or using any domain name, I can play the game normally.

Is there also a possibility to run a game in installation mode without the captive portal?

Motion & Orientation

Since Apple has changes the policy for motion and orientation settings it is necessary to ask the user for the permission. Without the user permission the orientation function will not work.

I would like to suggest to change the controller code with following code on the happyfuntimes server:

buttonEl.addEventlistener('click', function () {
DeviceMotionEvent.requestPermission().then(response => {
if (response == 'granted') {
window.addEventListener('devicemotion', (e) => {
// do something with e
})
}
}).catch(console.error)
});

Many thanks!
Martin

Installation mode on Windows

Hey I've made a quick game that I'm trying to show at a big event and would like to not have to rely on bad wifi but am having a lot of trouble trying to piece together how to setup installation mode. I think I have my router correctly configured. Is it even possible on windows?

iPhone 7 no pads are responding

Great work, and useful. But I have tried all variations for the demo phone controller and only the buttons work, none of the pads. No touches showing in the controller example. Any idea what's going on?

iPhone 7, iOS 10.3.1

Phone can't connect to laptop on IPV6 router

Laptop can connect to localhost fine through browsers but no phones can find game. Same setup worked on IPV4 but when I switched to IPV6 it no longer works. Let me know of things I could try to provide additional info!

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.