Apr 03 2015
I’ve just started a Unity project at work, so even though I started off with my little c++ program I have to devote my free time to Unity for some time now. And also, since Ludum Dare 32 is only 2 weeks away, and I decided to go with unity for it, there’s even more reason to continue with Unity development yet for some time.
This one is actually one of my earliest experiments. It started out good, but I couldn’t really get it to behave just as I wanted so I put it in the dust bag. It is a good way for me to realize just how much I’ve learned since then.
My main problem was that the character was getting stuck in walls if you jumped to the side of it, and kept pressing forward. Easy enough to take care of! Just create a custom material for your platforms and modify the friction values.
Another thing I had problems with was the 3d-camera. As it’s tilted it was getting closer and closer to the charater the further he got to the right. Just because I didn’t adjust the z position. Very simple.
I started experimenting with cube texture mapping. I think tomorrow I’ll start looking into how I can write a custom shader to do it instead of modifying the UV-coordinates in the Start()-section of a script.
<< Click to play >>
Mar 10 2015
Continued with the C++ project.
Noticed that the sample code for my triangle was in the older glBegin…glEnd format and changed it to the new opengl 3 standard with shaders, only to get a totally black window.
Turned out you need to add the following code to enable opengl 3 and core profile:
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
Which gave me a triangle once more.
The rest of the evening was spent re-reading about matrix operations, and the Model-View-Projection matrices. It was a long time since I last played around with this. You quickly forget if you do not keep working with it.
Mar 10 2015
Took a short break from the Unity project to go into C++land. Decided I wanted to play around a little with some C++ and openGL.
I wanted to develop on my Linux partition (why make it easy for yourself?) but make the code cross platform so I’ll still be able to run it on my windows machine. I decided I wanted to use glfw for all the window, input and timer hassle. It seems light weight, and it is used in this tutorial by my colleague at Isotop (he named the blog series “I’m not a smart man” for some reason. Trust me that it is very far from being true!)
So, did it go smooth? Not at all. I’ve spent a bit over three days trying to figure out how in *#¤% you manage to tell Code::Blocks how to find and link the libraries I want to use. I’ve covered it in a blog post, mostly for my own convenience. Probably full of incorrectness.
Well, now I have a spinning triangle in a window. Time to make something more interesting!
Mar 05 2015
Today I made the following new features
- Moved the project over to the newly released Unity 5
- Played with a particle system running as part of the background
- Started on wall jumping feature (based on public demand), this is not all done yet though!
<< Click to play >>
Moving the project over to Unity 5 went pretty painless, unless the collider offsets were messed up on my platforms, meaning I had to adjust all of them. Luckily the level isn’t that big, which meant it only took a few minutes.
If I had turned the platforms into prefabs (which would have been the right thing to do) this operation would only have taken a few seconds.
And I’ve been playing with the though of adding some background particles. I wanted some slow/smooth/subtle background noise. Well… I don’t know what to think of it. I could have spent the entire night tweaking it. But instead I moved on to the wall jumping part.
I have to say I’m very satisfied with the gliding part (just need to add some particles while slowly sliding down the wall), but the actual jumping-part is horrible. But that’s something I’ll have to fix another nigth. Now it’s time for bed.
Mar 02 2015
Today, with the platforms finally fixed, I started expanding the level. I’m not sure how Unity optimizes what goes on behind the scenes, so the only way to figure out is to try it out.
Also, it’s a good way to find out what features I feel like I’m missing. Like pick-ups, or enemies that or obstacles that will hurt you.
It also gives me some room to really try out the features I already got. Like the treadmills for example.
<< Click to play >>
Mar 01 2015
I haven’t been coding much (on my game, that is) for the past two months. Instead I’ve spent a lot of time watching the Handmade Hero stream. It’s really fascinating and I highly recommend it, but I’ve been having some code cravings lately. So I decided to go back to my platform engine again.
Last time I coded on it I left it in a rather poor condition, with some buggy moving platforms. The problem is that the Character2dController reports to the platform that it has collided with it, and the platform keeps track of the colliding entity and reports back its change in movement to the Character2dController. But the platform only held a single instance of the colliding object, meaning it messed up if more than one entity intersected it. The problem was solved as easy as changing the variable to a list.
Something that is very useful when debugging this kind of graphical application (with several entities with different state and values) is to be able to easily read state data. For this I’ve added debug output above each Character. This debug is a stand alone component, so I could easily add it to the moving platform as well, to verify that the list of colliding GameObjects counts up and down as expected.
Apart from this bug fix there’s no new features, so I don’t provide a new build today.
Feb 02 2015
Since the Christmas Holidays I’ve started watching the fairly new stream Handmade Hero, where we get to follow Casey Muratori, as he builds a game in C, from scratch, without any libraries, and streaming and explaining every single line of code that he writes.
I’ve been struggling with C++ for a while now, but it’s very difficult to find answers when you get into a situation where you need help with a specific problem. There are endless ways of solving the same problem in C and C++, and very often you will get contradictionary or incomplete solutions. And a lot of times people just answering “You shouldn’t do it like that” and then nothing more.
So I enjoy this video stream very much. Casey explains every single line of code he writes. And also sometimes explain other ways to solve a task, and why he prefers the one or the other. He also tackles some very advanced topics, like how to structure your code to get a good foundation for platform independance. And he does it very elegantly.
The stuff he teaches is not something you wouldn’t easily find in any text book, and corresponds to years experience, so I highly recommend watching.
At this point I’ve watched Episode 13, and coded up to episode 5.
I Haven’t anything more interesting to show right now than a simple window, with a simple animated buffer (rendered in software) in Windows. All I have to show for it right now is a simple Screenshot.
Jan 15 2015
Last time I promised a bigger world, and starting with animations. It seems I forgot a very important feature: moving platforms!
Todays build features:
- Moving platforms (still a bit buggy)
- The moving platform to the left is a Solid platform, you hit your head if jumping on it from below
- The moving platform to the right is a Cloud platform. You can jump on it from below, and jump through it with down+jump
Give it a try
Known bugs (to be resolved):
- The platform can currently only handle one colliding object. If two or more entities touch the platform very strange behaviour will occur.
- You can fall through a platform if you fall downwards and it moves upward at larger speeds.
And as a side note: I think the game looks better with Unitys debug stuff enabled. Don’t know if you can export the web player with those enabled. I think not…
Next time: Platform bug fixes and then performance on big worlds and animations.
Dec 29 2014
First of all, a disclaimer: I have decided to change the name from physics to platform engine from this point. Not sure how much more physics I will implement right now. I think from now on it’s time to focus more on trying to make this into something playable.
Todays build features the following:
- Bugfix for Treadmills reaction to player
- FPS Counter (in top left corner)
- Xbox 360 Controller support (at least on Windows), not sure if it works in web player…
- NPC:s with same physics component as player. Very simple AI controller
Give it a try
Finally the work started to pay off with decoupled physics. The input is also decoupled, meaning that I could just duplicate the player logic, remove the input script and attach a simple AI controller instead. Now we have a whole bunch of red NPC:s running and jumping around.
I think next step might be to build a larger world to be able to see if performance is doing ok in a larger setting. Otherwise I think that it’s time to start looking into graphics and animations.
Dec 27 2014
Try the current build
News in this build:
- Refactored character controller system (more on that below)
- Jump button is now space bar instead of up arrow (conflicted with ladders)
- Disable gravity while on ladders (was buggy before)
- Cloud platforms are disabled while climbing ladders (can climb down through them)
- Down+Jump while standing on a cloud platform and you jump down through it
- Removed that silly fist
Been some while since I last wrote now. Been doing some other stuff than Unity (some c++, and some updates to Ripple and its level editor). But now it’s time to get back to this little project again.
Something that bothered me a lot in the past was how fast it gets messy when implementing platform mechanics. You need need to keep track of if you are jumping, falling, standing on ground, climbing, ducking, sliding, hurting, attacking. And these states gets intertwined into each other. For example: what is a valid state for a charater to jump? He should be standing on the ground – unless if he’s climbing a ladder… or if he’s hurt or dead. And if the player pressed the jump button and the character lands on the ground without releasing the button then we shouldn’t automatically jump again until the button is released and pressed again.
My very small piece of code had already started to get messy this early on, so for a few days I’ve been refactoring it into smaller, more independant and stand-alone modules. This new version is completely rewritten, and all the previous functionality has been ported. Along with a lot of bugfixes.
Still the physics feels a little weird, so some more tweaking is needed. I guess next step is to implement some simple enemies with the same character controller…
Nov 03 2014
Late and tired tonight as well. Just a very short, and very unserious session tonight.
Been thinking about using Adobe Kuler (seems to have been rebranded to Adobe Color CC) to get a better palette of colors to use when working with programmer art as I currently do. The result wasn’t very impressive so I guess it needs a little bit more tweaking.
I also added a punching fist a la Alex Kidd, but the player doesn’t have anything to hit yet. And the ladders are still broken (will fix that in my next session).
Here’s a short demo of the punching fist
Oct 30 2014
Started on ladders today. But it’s late and I’m really tired so I’ll have to continue some other night.
Still happy with the result so far though! This will be awesome once I’ve tweaked it enough.
Try my ladder here
Oh, and by the way: the source code for this can be found here in case you wonder how I did stuff:
https://github.com/Tommislav/unity2dPhysics
Oct 29 2014
Been a while since last time I sat with this, but tonight I managed to get cloud platforms working.
So right now I have: Solid blocks, Cloud blocks and Treadmills.
Next up: Ladders and Elevators!
Planned after that (maybe): Gravity shift. Perhaps slopes… not sure yet.
Try it yourself!!!
Oct 20 2014
Been working a bit here and there on tweaking the scripts to the way I prefer them. Not really getting any visual progress, more just shuffling code around.
Takes some time since I’m not used to how to work with Unity. I know on a conceptual level how I want my code to work. But it’s starting to feel nice. Soon time to add treadmill-colliders =D
Oct 14 2014
I have found a fantastic tutorial series on 2d in Unity which can be found here (it’s several hours in length).
Not only do they build a complete game (instead of the usual one-screen-tutorials most others do), they also tackle complex subjects such as slopes and moving platforms. And they do it with really beautiful code! It’s very obvious that the programmer is extremely talanted. He manages to keep the code very clean and readable, and keep the abstraction levels very well separated. This is one of the best game programming tutorials I’ve seen in a very long time! I highly recommend it!
And after watching through it I started writing my own custom 2d physics. Why? Because I don’t like the built in for 2d games. You cannot do obvious things such as cloud tile collisions for example.
<< Click to play >> (move with arrow keys, press shift to move faster)