Sep 16 2018
Pretty much every experienced programmer I meet who starts working in unity does the same thing. They try to work around Unitys own way of doing things, and I was no exception. I have given this phenomenon a name: to Fight The System. Usually it ends up biting you in the ass, and have you do it the Unity way with your tail tucked between your legs.
But now I’ve been working with Unity full time for over three years, and a while back I got an idea too good not to try. It’s the ultimate Fight The System!
This evening I managed to complete minor milestone #1. Rendering tiles from an old Ripple Tilesheet to a runtime generated mesh, using a custom shader to map the tile values.
It does not scroll yet, but supports rescaling the viewport (although only to even pixels in height).
This is a good start!
Apr 24 2017
How do you create a nice user (developer) friendly Behavior Tree in Unity? The hardest part with BT’s is not making them, it is maintaining them! As they scale they become pretty hard to grasp, and you need good visual tools to debug. But I just got an idea that I want to write down somewhere before I go to sleep and forget all about it.
First some links
Introduction to BT’s, if you don’t know them:
Interesting project with viusal editor (though way to buggy to be used, and also I don’t like the performance warning in the readme):
Here is a rundown on how to create a similar visual editor, using Scriptable Objects:
And lastly, you might have to read up on ScriptableObject as well:
So, ScriptableObject has some problems for our usecase: It does not support polymorphism. So here is the idea on how to solve it.
- A BehaviorTree class, with custom PropertyDrawer
- All the basic nodes are built-in into BehaviorTree, such as Sequence, Parallel, Repeater and so on
- Custom Condition and Action nodes are added as MonoBehaviours to the gameObject (and thereby serialized with all their properties), but added by reference as a nodes in the BehaviorTree
It’s not a pretty solution, but to me it beats most of the other solutions I have seen. Then it’s just a matter of building that custom inspector for the BT.
Jan 15 2017
“Don’t worry about the dog, he’s very nice and only wants to play!”
Dec 15 2016
A while back I found all the raw material for a game me and Simon were working on a long time ago (actually before both Ripple and Metro Siberia, so somewhere around 2006 – whoa, thats TEN YEARS ago!!) called Kingsmountain, and I’ve been playing with the idea to try and recreate one of the minigames.
My first attempt was with Haxe, and a 2d skeletal animation tool called Spine. However, the Haxe runtime implementation for Spine was buggy as hell, and I spent many hours trying to animate the running little dude, but finally the bugs made me give up.
Instead I restarted the project in Unity, and here you can see the result after just about 2-3 hours.
Jul 11 2016
The source code for all 7 days can be found here: https://github.com/Tommislav/unity_shaderweek
It has been a successful and interesting experiment, commiting 7 days to shader programming. As I’m on parental leave I could only spend about an hour a day for this, but I think I managed to get quite far!
Apart from what’s visible here, I spent 3-4 days reading or researching, but did not count those as I wanted visible examples for each day.
One problem with only having about an hour a day, and only doing tutorials is that you don’t get much time to modify/experiment/fix bugs. But I early decided that my focus this week would be learning, and that I will do a second shader week where I experiment and create my own shader effects instead.
- I have learned a ton!
- Need a second shader week, where I write my own shader effects
- A superb resource for learning shaders is this link: http://www.alanzucconi.com/
Jun 30 2016
Todays shader tutorial was about keeping an offscreen buffer which we can update continually.
In the image to the left we invert the colors every second.
The right image was supposed to be smoke, but the tutorial was very math heavy but thin on how to do the implementation. So I skipped the smoke tutorial and made a script myself that draws a circle at the mouse position (cursor not visible in gif) and fades the image by 0.9 every frame.
Good thing the cursor isn’t visible though. Somehow the mouse X/Y-movement was inverted, and coordinates messed up.
But not enough time to fix tonight, as I’m only using an hour a day.
Jun 29 2016
Finally started on vertex and fragment shaders again!
GrabPass to grab a texture of what’s underneath we can manipulate whats underneath.
The red rectangle is just taking the rgb + r*1.5, applied to a quad.
Underneath we’re using a bumpmap to apply something that looks like glass.
Very cool, but a lot of new concepts here. Will have to play around with this more. But now I’m out of time for today…
Jun 26 2016
Today I started with a tutorial series that seems to be very elaborate:
This tutorial starts with an overview, and then goes on to surface shaders. I decided to start from the beginning, but did not manage to complete the surface-part in just one hour.
The Vertex/Fragment-part comes afterwards and is the part I’m looking forward to.
Knight number 1 (from the left) is the original. Free model from Asset Store
Knight number 2 is a surface shader that only sets the albedo property (base color).
Knight number 3 uses the texture data (but no specular or bumpmap or other fancy things)
Knight number 4 uses the built-in
worldPos input variable to paint a circle - based on distance from a point in world space.
Jun 21 2016
First of all: installed Visual Studio Extension to get some basic autocompletion when writing shader code. An improvement!
Second, was looking for how the sampling of pixels was working and found CG documentation:
http://developer.download.nvidia.com/cg/index_stdlib.html (look for tex2D-function)
Apart from that, I finished off the tutorial from yesterday (interpolated colors into the rendered texture), and then proceeded with applying a shader to the camera for full screen effects - using OnRenderImage(src, dest) and Graphics.Blit(src, dest, material).
Finally played a bit by adding a displacement map, distorting the entire screen. Simple stuff, but still funny!
Jun 20 2016
I have collected a number of interesting resources for starting to get acquainted with writing shaders in Unity, so I have decided to devote an hour a day this week to start going through them (I think I can manage an hour a day, but not sure… I’m currently on parental leave with my two 11-months twin girls. I’ll do as best as I can).
Here are the resources
After this first hour I’ve gone through the first Shader101 in the top link. Simple stuff. Drawing colors and/or a texture to a quad. With and without transperancy.
However, the tutorial lacked depth. And I spent the rest of the hour trying to find out more about the sampler2D-class used to sample pixels from the texture to the quad. Without luck.
However I found an interesting link on how to make Visual Studio better at writing shader code. Will look at it tomorrow! https://visualstudiogallery.msdn.microsoft.com/ed812631-a7d3-4ca3-9f84-7efb240c7bb5
Jun 19 2016
In tonights short coding session I added two new components.
A tagging system for entities.
Unity already has a way to add a tag to gameObjects, but for me “tagging” means being able to add several tags to an object, which Unity does not support. Something can be tagged both as NPC AND a Human.
Second, I added a new (very simple) AI-component that will rush towards player or NPC if standing in front of it.
It utilises the tagging system to get a list of all entities tagged as either “player” or “NPC”, check direction and distance, and start charging!
As you can see, the Hedgehog speeds up if either NPC_Joey or the player is in front of it (although the graphics does not flip correctly yet).
Jun 11 2016
A while back my friend Steve asked me if he could use my old platformer engine for a game he wanted to do!
I was very happy to see it come to use!
The engine is open source btw, and can be found here: https://github.com/Tommislav/unity2dPhysics.
But tonights short coding session involved a fix to the physics system to detect when someone is “over a ledge”.
The hedgehog enemy in the image above will switch patrol direction if either hitting a wall, or getting over a ledge.
The guy with the white hat is my old AI, who just moves in random directions for a random amount of time. In my last post he was a red box. Steve has drawn and animated him quite nice!
Feb 29 2016
Sidetrack! I got an idea that I really wanted to try.
Removed the player and focused only on playing with the level design.
Imagine that you are running around on a scaffolding structure really high above the ground. Running, jumping, swinging.
That has always been a dream of mine (if I had more than one life). I guess that’s why I love platformers so much…