Sign in to follow this  
Dinosaursssssss

The Unity Thread

Recommended Posts

We have a couple Unity threads but it seemed like a general purpose thread for sharing cool projects, asset store stuff, talking about new features, etc would be useful to keep things contained. If you're looking for tutorials or have questions, check out these threads:

 

Unity Tutorials

Unity Questions

 

Anyway, I just got back from Unite Boston, which was the main Unity conference this year. Lots of cool stuff coming soon, one of the coolest new features they showed was the new 2D tile maps (which seem awesome). They showed a bit during the keynote:

 

 

There was another longer presentation that went more in depth that elicited audible gasps and cheers from the audience, but it's not on youtube yet, though there is an alpha available for pro users here. All the talks are going up eventually, so when they do I'll post a few recommendations of other stuff I liked.

 

A couple other handy features announced were that Ads and Analytics are getting fully integrated into the client, and they're adding support for mobile IAP so people won't need to write their own native Objective-C/Java code just to handle microtransactions. Super boring features I wouldn't have cared about a year ago, but having dealt with all that stuff over the past year, sounds like an awesome time saver.

 

Another feature announced was the 'Made with Unity' program, which they pitched as a way to increase discoverability, but actually just seems like some kinda slapdash user blogs. Here's mine.

 

Anyway, Unity. It's cool. What asset store stuff is invaluable to you? What sweet Unity thing have you seen recently? What do you want more, multi-scene editing, or nested prefabs?

 

https://www.youtube.com/watch?t=2&v=L7-zRWai5yY

 

Also check out #unitytips Tuesday on Twitter.

Share this post


Link to post
Share on other sites

Completely off-topic and mooching, but does anyone know if there's a free trial for Unity Pro? 

Basically, I just want to try out to Image Effects stuff like Sun Rays, Fog, etc. but don't want to pay the full amount for Pro or go to the asset store just to have a test drive with them. 

Share this post


Link to post
Share on other sites

Completely off-topic and mooching, but does anyone know if there's a free trial for Unity Pro? 

Basically, I just want to try out to Image Effects stuff like Sun Rays, Fog, etc. but don't want to pay the full amount for Pro or go to the asset store just to have a test drive with them. 

 

You used to get a free 30 day trial of pro, but I used mine over a year ago. Sounds like you don't  need the Pro license now, but in case something come up later...

Share this post


Link to post
Share on other sites

Gaining access to all those pro features with 5 was such a godsend! That said, I'm using them in a game now and the edge detection is unsatisfactory (even with over an hour's worth of tweaking) and the bloom introduces a horrible and hilarious rendering bug.

 

Looks like I get to learn how to write screen space shaders if I ever get the motivation to push through the hard stuff...

Share this post


Link to post
Share on other sites

After watching a tutorial on how to recreate Doom's first level with Probuilder, I've been working with Probuilder a lot and getting much better at it. I've tried to stay away from creating architectural spaces in games because I want-to-want-to concentrate on interactions and characters, but making decisions like that tend to plug up my creative output and I'm seeing that now as I've been working on my architecture project with Probuilder on a regular basis for fun after very slow progress on character-based narratives. Probuilder is an awesome tool for me because I need to be able to build and manipulate 3D meshes and texture individual surfaces within Unity; constant go between and importing would ruin the iterative process for me. It's a great tool (especially with Progrids).

Share this post


Link to post
Share on other sites

Another good Unite '15 talk, this one from local Boston dev Ziba Scott. The talk is kinda about coding a buoyancy system, but to get there it also goes over about a bunch of generally useful math and Unity topics like vector math, threading, etc. I got a copy of Ziba's water system a while back and had a fun day making some little demos with it, and it's for sale on the store now if the talk gets you curious: Advanced Buoyancy - Popcannibal

 

Share this post


Link to post
Share on other sites

I just tried adding a basic buoyancy to the character-controller based off of that video. I had to switch to a rigidbody character-controller and make all sorts of fixes for my particular situation. It's goofy as shit, but I kinda like it.

Share this post


Link to post
Share on other sites

There's some really smart techniques in this, the planet stuff may be of particular interest to Dino.

 

Share this post


Link to post
Share on other sites

There's some really smart techniques in this, the planet stuff may be of particular interest to Dino.

 

Yeah that talk is amazing, probably my favorite from the conference. Definitely a must watch for anyone doing professional mobile development or...space stuff. A lot of what they talk about is kinda beyond me though; I think I need to learn a lot more about writing shaders before I'll really be able to make use of it. 

 

Your procedural planet thing looks good! I started working on something very similar but didn't get quite as far; it took me a little while to grasp how Unity stores triangles/verts. Here's my hilariously bad first attempt: 

 

wI1fGIA.png

 

This is from a few days ago, but if I remember right these were getting the same deformation script run on them, but the left one has hard edges.

Share this post


Link to post
Share on other sites

Cool, I'm using a shader (made in shader forge) so it's relatively easy to get something vaguely resembling the goal but seems to be rather hard to get it much closer. I've been noodling around with it all day on and off and I've not really made much progress :)

 

This is using tri-planar mapping with a couple of noise textures, I would prefer to not have to use textures but the built-in noise in shader forge is a bit limited and tricky to modify. Also it would be nice if it worked independently of UVs for obvious reasons.

w6Cikn7.png

 

So you're modifying the mesh in code?

Share this post


Link to post
Share on other sites

So you're modifying the mesh in code?

 

Yeah, it wasn't really in my original design but having proper collisions on the planet geometry seemed like it could open up some possibilities. Though really I think the reason I went this route was I continue to be unreasonably scared by shaders.

 

The main problem I ran into is that all the triangles in the mesh are stored in an array, where every 3 indices are the corners of a triangle (ie, mesh.triangles[0], mesh.triangles[1], mesh.triangles[2] is one triangle) and if the edges are hard, each vertex appears multiple times in the array, so actually figuring out what triangles are connected and properly shifting the ones close to each other was more work than I anticipated.

 

Maybe that's a standard thing, I donno, my knowledge of how meshes work is pretty limited so this has been slow going. I think to do this right I need to do some pre-processing and maintain a list of which triangles are adjacent and which vertices in the triangle list are actually the same. I spent a night fiddling and would like to get back to it, but there's a mountain of other work I'm trying to get done first.

 

Anyway, yours look awesome! I should really just accept that I'm too lazy to learn shader programming and buy shader forge.

 

edit: If anyone's curious, here's the code. Note that my GetAdjacentVertices method sucks and does not work, so I'm not including it, and also I didn't actually test if the collider updated. Also I'm not actually sure I need to recalculate the normals or optimize, but the snippets I saw online did, so I am too for now.

//Takes in an icosphere mesh and makes continents on it
void MakePlanet(MeshRenderer meshRenderer) {
    MeshCollider meshCollider = meshRenderer.gameObject.GetComponent<MeshCollider>();
    MeshFilter meshFilter = meshRenderer.gameObject.GetComponent<MeshFilter>();
    Mesh mesh = meshFilter.mesh;

    Vector3[] verts = meshFilter.mesh.vertices;
    int[] triangles = meshFilter.mesh.triangles;
    Vector3[] ContinentCenters = new Vector3[NumContinents];

    for(int i = 0; i < NumContinents; i++)
    {
        List<int> adjacents = GetAdjacentVertices(meshFilter.mesh, Random.Range(0, verts.Length));

        foreach (int adjVertex in adjacents)
        {
            Vector3 point = verts[adjVertex];
            Vector3 outwardDir = (point - Vector3.zero).normalized * ContinentHeight;
            verts[adjVertex] = point + outwardDir;
        }
    }

    mesh.vertices = verts;

    mesh.RecalculateBounds();
    mesh.RecalculateNormals();
    mesh.Optimize();

    meshCollider.sharedMesh = null;
    meshCollider.sharedMesh = mesh;
}

Share this post


Link to post
Share on other sites

Unfortunately I know less than you about mesh coding.

I wonder if there's a way to convert a vertex offset mesh to a solid mesh? I could do it in 3D Max with displacement but that's a very different situation.

Share this post


Link to post
Share on other sites

I've done a bit more. Annoyingly since web player is dead and web gl doesn't seem to be working on my site so I've had to make a standalone build, if anyone wants to have a look it's here: http://bretteveleigh.co.uk/other/Planetoids/Planetoids_Standalone.rar

 

Edit: The nice people at my hosting company fixed if for me so here's the web gl version: http://www.bretteveleigh.co.uk/other/Planetoids/Build/index.html

Share this post


Link to post
Share on other sites

Alright, all the Unite talks are up so I'm gonna finish recommending stuff.

 

 A must watch if you're doing mobile engineering or graphics optimization.

 

 

, from the awesome Elliot Mitchell, who runs the Boston Unity Group.

 

I didn't actually watch this one (yet!) but a bunch of people recommended it.

. Alex organized the Valve sponsored VR jam here, and has been working with the Valve VR hardware for quite a while, so he knows his stuff.

Share this post


Link to post
Share on other sites

I spent a while last night messing with image effects and shaders, trying to get my UI to have a nice inward curve. I found a super useful tutorial that got me most of the way there, but I'm not sure what I wanna do can be done using the Unity UI system. It seems like camera effects can't be applied to specific cameras or layers, as (I guess) the source image parameter for OnRenderImage() is the final image with all the cameras combined. I tried a weird solution where I put all my UI on a rendertexture that's laid over the over the screen on a quad, but I couldn't get it looking good, so I'm not sure what I'm gonna do. 

Share this post


Link to post
Share on other sites

I spent a while last night messing with image effects and shaders, trying to get my UI to have a nice inward curve. I found a super useful tutorial that got me most of the way there, but I'm not sure what I wanna do can be done using the Unity UI system. It seems like camera effects can't be applied to specific cameras or layers, as (I guess) the source image parameter for OnRenderImage() is the final image with all the cameras combined. I tried a weird solution where I put all my UI on a rendertexture that's laid over the over the screen on a quad, but I couldn't get it looking good, so I'm not sure what I'm gonna do. 

 

I was just about to start looking into CRT effects for a possible project I'm working on. This tutorial is a great start, although I might run in to similar problems you're having as I only want part of the screen to have that effect in a 2D game. I don't know enough about it to help you with your dilemma though... Maybe you could post sketches of what you want it to look like?

Share this post


Link to post
Share on other sites

Basically what I wanted to do is apply the distortion part of that CRT effect to my UI to make it looks as though the hud is being displayed on a curved space helmet. The problem is you can't selectively apply an image effect like that; it always has to apply to the entire screen. I think? I'm certainly no expert, but I googled around and it seems to just be a limitation of how image effects work.

 

The workarounds I can think of are, 1, what I attempted, which is to put all the UI into a render texture and overlay that quad on the camera view, or 2, to build the entire UI in 3D and write a shader with a similar effect that I use on every ui element. I kinda wanted to build the UI in 3D anyway so I'm gonna be investigating that approach I guess.

Share this post


Link to post
Share on other sites

You can also try adjusting the viewport of your UI camera (I think that's what it's called) and applying the image effects only to that. Really Unity's shader system is just OpenGL commands as far as I understand it so you shouldn't be unable to do anything (it being performant another question entirely). I'd ask around the Unity forums and hopefully someone who knows more about shaders than I do can point you in the right direction. You might also want to look into blendmodes and distortion effects like fisheye and that thing where a grenade goes off and a localized warp takes place (I always forget what it's called)

Share this post


Link to post
Share on other sites

OK, so.  Where to begin.

 

I've been programming for 25 years, 10+ professionally, but I've never tried my hand at games.  For reasons unclear even to myself, I've recently taken an interest in games programming, to the point of actually downloading Unity and working through a few tutorials.

 

The framework is always harder to learn than the language.

 

I picked Unity only because it seems to be snowballing.  The best framework, for me, is the one I can get the most help with.

 

I've worked on large projects in C, perl, common lisp, scheme, java, scala, ruby, bourne shell scripting (god help me), javascript, and several DSLs that escaped containment and grew into shambling half-designed full-blown languages.

 

My problem is not learning C#.

 

My problem is that it seems like programming games in any modern framework means I have to give up even the puniest, least powerful conveniences borrowed from functional programming that I've grown accustomed to in non-games languages and frameworks.

 

Things like map(), fold(), and filter().

 

Apparently you can't use LINQ in Unity without utterly ruining performance.  You can't even use foreach in lieu of a for loop?

 

Mind you, I really don't have anything fancy in mind for a first outing; I've been inspired mostly by the Tower Defense episode of Three Moves Ahead.  But though it's mechanically simple, that's a type of game where you're going to be manipulating a lot of collections of objects, you know?

 

So... do I really have to give up ten years of progress and go back to lots (and lots and lots and lots) of nested for loops?  Is Slinq still viable, even though development stopped two years ago?  Does anyone in the world of games programming even care about this, or am I just being a whiny baby?

 

And threading?  Does Unity even use threads under the covers to do physics and stuff, or is it just completely single-threaded apart from whatever you're brave enough to cowboy up on your own?  I've done a fair bit of concurrent programming -- I even added multithreading to the core engine of a stinkin' IRC bot, for heavens sake -- but no modern off-the-shelf game engine has any built-in support for asynch jobs, actors, worker pools, promises, futures... any of that sort of stuff?

 

OK, I'm complaining.  I'm... I'm kind of aghast, and I realize that's not attractive.

 

But can some kind soul hold my hand and tell me everything is going to be OK?

Share this post


Link to post
Share on other sites

I honestly didn't realise there wasn't threading support in Unity. I'd be even more surprised if Unreal didn't offer it.

 

Unreal is also in C++ so heck it might be better just to try that out and see where you get in a month or so.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this