All Projects → Thorium → Roll-a-ball-FSharp

Thorium / Roll-a-ball-FSharp

Licence: other
Unity 3d game engine tutorial (in F#)

Programming Languages

F#
602 projects

Projects that are alternatives of or similar to Roll-a-ball-FSharp

Unitylibrary
📚 Library of all kind of scripts, snippets & shaders for Unity
Stars: ✭ 1,968 (+1928.87%)
Mutual labels:  unity-tutorial, unity-3d
Unity3D-Cars
A project built for a Renaissance Coders tutorial to introduce vehicle physics.
Stars: ✭ 60 (-38.14%)
Mutual labels:  unity-tutorial, unity-3d
UnityDebug
A wrapper script for Unity debug calls to use conditional attributes in order to avoid debug code being compiled into release builds.
Stars: ✭ 29 (-70.1%)
Mutual labels:  unity-tutorial, unity-3d
Velocity
Weird jumping game
Stars: ✭ 32 (-67.01%)
Mutual labels:  unity-3d
streamdeck-unity
Enables Stream Deck integration with Unity.
Stars: ✭ 22 (-77.32%)
Mutual labels:  unity-3d
engine-plugin-unity3d
Unity3D plugin for iFun Engine
Stars: ✭ 15 (-84.54%)
Mutual labels:  unity-3d
unity-cheat-sheet
C# Cheat sheet for Unity
Stars: ✭ 53 (-45.36%)
Mutual labels:  unity-tutorial
QuietVR
A Quiet Place in VR: Generate any 3D object with your voice. It's magic!
Stars: ✭ 17 (-82.47%)
Mutual labels:  unity-3d
GalaxyBreak
Galaxy Break is a minimalistic endless video game for mobile published for Android platform.
Stars: ✭ 21 (-78.35%)
Mutual labels:  unity-3d
unity-smooth-movement-test
Try and compare movement types in Unity
Stars: ✭ 22 (-77.32%)
Mutual labels:  unity-tutorial
Unity-Tanks-Tutorial
Unity Tanks Tutorial: Completed Project Files & Phases Summary
Stars: ✭ 22 (-77.32%)
Mutual labels:  unity-3d
bhl
bhl is a strictly typed programming language specifically tailored for gameplay logic scripting.
Stars: ✭ 20 (-79.38%)
Mutual labels:  unity-3d
XRAcceptanceTests
This project is used to verify behavior of Unity configurations, compare features between Unity releases, and test for changes in performance.
Stars: ✭ 33 (-65.98%)
Mutual labels:  unity-3d
50-unity-tips
A collection of 50 tips for Unity (focusing on Mobile) ranging from editor tools to serialization to UI shortcuts.
Stars: ✭ 80 (-17.53%)
Mutual labels:  unity-tutorial
Unity-Lua
A wrapper around MoonSharp that allows easy development of moddable Unity games
Stars: ✭ 105 (+8.25%)
Mutual labels:  unity-3d
com.unity.netcode.gameobjects
Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
Stars: ✭ 1,678 (+1629.9%)
Mutual labels:  unity-3d
Boids-2D
My simple, tiny, tidy take on the classical Boids algorithm by Craig Reynolds. #MadeWithUnity
Stars: ✭ 19 (-80.41%)
Mutual labels:  unity-3d
JsonFormatter
Easy, Fast and Lightweight Json Formatter. (Serializer and Deserializer)
Stars: ✭ 26 (-73.2%)
Mutual labels:  unity-3d
A-Distant-Path
3D multiplayer puzzle game made for Ubisoft's Game Lab Competition
Stars: ✭ 18 (-81.44%)
Mutual labels:  unity-3d
unity-tools
A Visual Studio Code Extension to provide some tools for Unity development
Stars: ✭ 25 (-74.23%)
Mutual labels:  unity-3d

Unity tutorial: Roll-a-ball F-Sharp

Unity is a multi-platform (3d) game engine. The basic version of Unity is free.

This repository is the first [tutorial from Unity] (http://unity3d.com/learn/tutorials/projects/roll-a-ball/).

The only difference is that F# programming language is used. No neat functional source code, just plain translation.

It seems that Unity doesn't lock the dlls, so you can build new versions on the fly and still Unity keeps bindings which is great.

You have two options, a) either start from scratch or b) run this solution.

How to make a similar solution from scratch

  • Install some version of Unity and a Visual Studio (or MonoDevelop Add-in F# language binding)
  • Create a new Unity project as usual (Instead of desktop I recommend to put the project something like c:\git\Roll-a-ball ) [http://unity3d.com/learn/tutorials/projects/roll-a-ball/set-up] (http://unity3d.com/learn/tutorials/projects/roll-a-ball/set-up) But before proceeding to the second video...
  • With Visual Studio (or MonoDevelop or your favourite editor...) create a new F#-library under your Unity's project path. Un-tick the "Create directory for solution" to save one directory. (I used c:\git\Roll-a-ball and created project called GameLogic.)
  • Add references to UnityEngine.dll (I did have it in C:\Program Files (x86)\Unity\Editor\Data\Managed\ )
  • From project properties, set the build "Output path" to some folder under Unity's Assets-folder, for example: ..\Assets\bin\
  • It seems that Unity 4.x still uses .NET 3.5 (or 2.0) so it is better to change the target framework to .NET 3.5. (I don't know what is the MonoBleedingEdge-folder under Unity, maybe they will update soon...)
  • If you want to be sure to use same components as Unity, replace also mscorlib.dll, System.dll, System.Core.dll from the ones that are found under Unity's folder structure (I have those in C:\Program Files (x86)\Unity\Editor\Data\Mono\lib\mono\2.0\ )
  • For FSharp.Core, the copy-local should be "true" as Unity doesn't have it. These other core-level dll's should have that "false".
  • Write some script, e.g. like this:

namespace RollABall
open UnityEngine

type PlayerController() =
    inherit MonoBehaviour()

    [<SerializeField>]
    let mutable speed = 6.0f

    member x.FixedUpdate () =
        let ``move horizontal`` = Input.GetAxis("Horizontal");
        let ``move vertical`` = Input.GetAxis("Vertical")

        let movement = Vector3(``move horizontal``, 0.0f, ``move vertical``)
        movement * speed * Time.deltaTime
        |> x.rigidbody.AddForce

  • Now, build in Visual Studio, then switch to Unity and open bin-folder from Assets. From Project-window, you should see your fsharp-dll and a little arrow on its right side to extend the details. When you press the arrow, you see the class(es) inside the component and you can directly drag and drop your class to your game object (like the ball in this tutorial).
  • Then just continue the tutorial, but instead of creating every snippet a C#-file, just code F#, build the solution (in VS) and Unity notices the new modifications on the fly.

How to get this repository code running

  • Install Unity (4.6.1-...)
  • Install Visual Studio 2015 (CTP)
  • Open and build GameLogic\GameLogic.sln with Visual Studio. (Leave VS open...)
  • Open project with Unity: Roll-a-ball-FSharp (Yes, the whole folder).
  • Open Scene: _Scenes\MiniGame.unity
  • For some reason Unity may have lost the references. So you have to map those once: from Hierarcy-tab select Player, then from Inspector-tab under Player Controller (Script) select the small circular button next to Script-textbox. A dialog opens then select PlayerController from the list. Do the same for (Hierarchy-tab again) Main Camera, associate it (from Inspector-tab again) to CameraController. Then from Project-tab under Assets go to Prefabs and select PickUp (Cube-icon). From the Inspector-tab select Rotator (Script) and assign it to Rotator. That's it.

Links

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].