Thursday, November 27, 2014

30Daydev: Day 5 - Why I'm shifting to learning C# coding On #Unity3D instead of #Playmaker for 2D games

I often said that I'm very bad with code, but I started to learn C# for Unity3D, OMG! Right? Lol I think I'll survive :) So why did I shift to C# now? I'll explain a bit, but just before, quick intro situation.

The day before yesterday, I was able to finish one first 2D Playmaker tutorial made by Romi.
It was basically just going left and right, jumping, and controlling respective animations.
T'was cool and everything, but too basic for my needs, I need more flexibility with controlling animations. And it may be more related to using Unity3D than just Playmaker.

For example the "unofficial" 2D Playmaker tutorial for a platformer character used a very basic way of animating a jump. And from having created relatively advanced animations before (multiple sprite parts pinned to one single box sprite at different points, in a modular form, frame by frame,) I need to learn how to use my same methods again, and Unity3D seems to have what it takes for that and probably more. Which is why i'm taking a pause from Playmaker, and will follow C# tuts which offer a lot more techniques variety for my current level.

In any case, the introductory video about Playmaker already warns you: Playmaker videos won't teach programming logic for Unity, but just how to use Playmaker to actually apply the programming parts in FSMs instead of direct code. Fair enough, no one can do everything at once right?

I asked if there were any more up to date tutorials for 2D platformers with Playmaker on the community Skype group, and I've been told that someone was working on newer tutorials that take the newer Unity 2D tutorials and examples of the Unity asset store for platformers and apply them with Playmaker. I hope they were already available but I'll just have to be patient for those to be available.

I also saw some commercial courses for Playmaker for 2D, but they still look too basic for my needs.

Conclusion: I'm shifting to C#! It will allow me to learn different ways, Playmaker already helped me to have an idea of Unity programming logic, and I may use it again once I learn more techniques with C#. Besides, I've always planned to to learn C#, so as I like to mention, there no better time than now, and no better place to start than on a Unity video game project, or so I hope!

Oh, and another thing that encouraged me to shift at last to C#: I remembered that many programming languages allow infinite amounts of comments within the code, without ever affecting performances or anything at all related to how the program will be executed! That means I could add a lot of descriptions to each single line, explaining and reminding myself why i'm using it and how it works/what it is used for, perfection eh? I think it can't get better than that. I can't do that with Playmaker, I use an external document for taking notes, I use that one too for C#, except that now with C" I can split the notes between the main text document for methods, and deeper details right on the  C# script code sheet, it's working out perfectly so far, I wonder at which point I'll feel good about shifting back to Playmaker, or not, I'll see! :)

To be continued...

Friday, November 21, 2014

30Daydev Day 3+4: Playmaker FSMs+ Joining Unity & Playmaker Skype groups

These two last days, I didn't do lots of progress programming-wise, I'm using more time on some online biz stuff that are separate from game dev goals, but I'm still satisfied with what I'm at right now: I cleared some important initial questions (like what version of Unity to use,) which I got answers two upon joining Playmaker and Unity communities on Skype groups, turns out I can install different versions of Unity side by side (by simply using a different folder name, how cool is that? :) (I'm using Unity 4.5.5f1 right now and downloaded the latest Unity 4.6 "stable" beta yesterday -didn't know stable beta was a thing-)

I also had a weird brain-experience:
In the beginning, I started studying an official Unity live training for 2D Character Controllers, at some time Mike Geig delved into C# code for controlls, I felt like I was going to sleep on the keyboard, my brain can't handle pure textual lines of code right now, or so that was what I thought.

After using just a small bit of the Playmaker 2D tutorial, and going back to the official live training by Unity, I suddenly found the C# code much simpler than how I looked at it before, because I got some basic logical understanding of how it works, (basic controls etc) which leads me to think that maybe (just maybe,) I may be able to start learning C#, yet I'll be very careful with that at this stage, I may prefer going more in the heart of using Playmaker before venturing into C#, I'm not a natural coder, from what i tried before (C long ago, and Javascript not long ago, was demotivated at some point, can't really explain why, maybe because this brain has difficulty in remembering what terms to use, maybe syntax, not sure...)

Day 3: Basic 2D commands using Playmaker + Playmaker 2D addons

I did just a quarter of a tutorial where I controlled a character with left and right controls, and created a jump action on my own.

What I learned here was:
1- Playmaker needs to install two add-ons for Unity in 2D mode: Mecanim (Playmaker 2D animation add-on) and Playmaker 2D actions, one of them is the Playmaker 2D animator (I don't remember exactly, because once you import the packages their name change. A bit confusing but not a big deal.)
The add-ons for 2D are here for now (21 Nov 2014)
Playmaker 2D add-ons

2- There are already many ways of controlling things like Jump: I tried to make a jump on my own and it worked using the left and right methods, just had a problem with endless jump, which invited me to continue observing the tutorial's techniques :)

The result is I made one Playmaker FSM (Finite State Machines) for left and right controls, and one FSM for the jump action. Here's the first for right and left controls:



Second Playmaker FSM, for jump:





Day 4: Joining Unity and Playmaker respective sofficial Skype groups 

It was very cool to join both Unity and Playmaker Skype groups, many helpful devs there, it inspires me the idea of joining all the main engines communities like Game Maker, UE4 and Clickteam's Fusion, but I have to be realistic, I don't have more than one brain and two arms, not yet, at least :)


That's it for today, to be continued :)

K'

















Tuesday, November 18, 2014

30Daydev Day 1+2: Going through Unity Basics + Making a SpriteSheet

Whew, these two last days I had big Internet problems, almost impossible to be connected for more than a couple of seconds at a time, but I continued studying Unity3D manual and small bits of live training videos I could glean out of this Traitorus Internets... at least it looks like working since some minutes, hopefully I'll keep it like that!

Real difficulty number one: Unity3D requires importing frames of animations as a Sprite Sheet only, I was surprized there was no other way, like single frames batch import in Construct 2.

So how to create a Sprite Sheet out of single frames exported from Brashmonkey's Spriter, and without being able to download any Sprite Sheet software or looking up the question online? Well I had to invent a way, never created a sprite sheet on my own, so I tried to create one with Construct 2, basically included frames of animations I made in the past (Leia from a paused Construct 2 project: Chivalrous -platformer-) and exported as HTML5. Unfortunately, the result was 3 separate Sprite Sheets for a running animation... and I needed one single sprite sheet.

Leia running - 8 first frames from 20.
Meanwhile, Internet came back a bit so I could download the first sprite sheet tool I could find on Google: TexturePacker, tried it and discovered it needed an importer (free) for the Unity Editor. And obviously Internet escaped again, leaving me face to face with a TexturePacker that transformed two of the 20 frames into a red filled silhouette at a PNG export step, and in a wrong order of frames... damn TexturePacker!

So I decided to just get some inspiration from TP for the size of the sprite sheet, 1024*2048 pixels, sounded cool, I used that, and following Unity's set of features, I imported my own spritesheet, and sliced it with a 2 pixels offset on the Y and Z, alligned top left, (while keeping the max size of the import to 2048, following the steps from the live training in the "Character Controller" video by Mike Geig, cool guy btw, like how he explains things.)



What else, oh! I figure out how to export PNG from Krita, I had difficulties just before, it was just a matter of getting the right settings (8 bit depth, RGB etc.) Later on I could download a more recent version, I was using 2.8.1 and found out there was the stable 2.8.3, I would have thought the updating was automatic, but apparently no... so, no big deal, the thing's solved :)

I'm still learning how to animate a Sprite but I'm getting close the the heart of the cool stuff (so many steps to do simple things! But I guess it will be worth it since it may allow more control, probably,) so that's it for now. Maybe I'll spend the night continuing to study stuff since the Internet seems to be back to life at night only :)

Almost sure I forgot some other details but in general, this is it for now. Let's see if I can get a demo level working by the end of the first week :)

Karim.

Sunday, November 16, 2014

#30daydev Day 0: Learning Unity3D, Playmaker and Krita

So tonight I'm ready to start learning #Unity3D the famous video game engine, #Playmaker the visual scripting tool for Unity3D, and also #Krita the graphics design tool allowing both vector and raster graphics with some advanced painting brushes. I'll be using Brashmonkey's Spriter for modular animations but i'll need to learn how to integrate them inside Unity.

Regarding Krita, I cheated a little bit since I started learning it two days ago, and already grasped the basics; tested the vector art tools and the brushes/basic tools, and I must say that despite some difficulties (lack of documentation because I'm using a Beta, didn't notice immediately,) it's coming along pretty well and I can now focus on learning visual scripting/programming with Playmaker.

We'll see where the #30daydev will lead me :)

My first drawing using Krita, after two days of intense practice hehe -using my Wacom Bamboo Pen smallest size (a random character I imagined, as always I never know what will come up from this brain :) :


Friday, November 29, 2013

How I developed my procedural level generation system for my HTML5 runner game (Construct 2)

Hi everyone, in this article I will explain very quickly the basic idea that I came up with in order to generate whole levels in a controlled and progessive method, for my first html5 mobile game called "Moto Runner," (aimed at Android, iOS, Windows Phone 8, Tizen and as many mobile device platforms as possible.)

UPDATE January 17th 2014: I wrote a simplified tutorial on Scirra.com's tutorials: Procedural Level Generation Using Global Variables and Collisions and included the CAPX file, test it out! : ) 

Below is a screenshot of my opened project in Construct 2: 

Notable elements:
  • PlayerBox: the blue square box near the center left (it has a platformer behaviour)
  • SeqTrigger: the red or orange high rectangle spanning almost the whole game screen height: it has a bullet behaiour, 
  • The three platform frames: frame 2, 0 and 1, which form the solid object on which the platformer character will run and jump.

Tip: Click images to enlarge them.
Image#1: My Construct 2 first html5 video game project opened (*.capx.)


The following are the Global Variables for the game, you'll find descriptions for most of them, I deleted many of the ones I created before, so only a few of these are no longer used, but most still are. 
Image #2 - Global variables event sheet - Construct 2 project



The Opening Bal!
I chose that name because it's really there that everything started!

Basically; here's what happens in the game:
- The platforms scroll as bullets towards the left.
- Playerbox is simulating pressing right, in order to run on the platform solids toward the right.
- SeqTrigger (orange rectangle) which has a bullet behaviour, is set invisible, and runs in opposite direction towards the PlayerBox (-I'm actually using a Spriter animation for the PlayerBox, not displayed yet here-)

When SeqTrigger (intended for Sequence Trigger) collides with PlayerBox: a value of 1 is added to the SequenceOrder Global Variable. This variable will decide which pre-organized spawning sequence will happen. And the actual Spawning Sequence is controlled by another global variable called SpawnSequence.

So: SequenceOrder is like a slot to organise orders (can be considered like just numbers) and SpawnSequence is like the value that calls a spawning of a particular number of objects, in this case the solid object on which playerbox runs, and those objects are created by the System.

I had to add a number of variables to control exactly all the conditions that will let the main global variables change their values, like spawnmax, and spawncount (see descriptions in the Global Variables event sheet, in Image #2.)

All the rest then is controlled by the "Series" Global Variable.

Each series contains as much "SequenceOrder"s as you want.

In my case for this runner game, I am using about a maximum of 22 or 23 sequenceorders per series, and about 3 series per level (layout) for now, just so I keep track of what I'm doing, but otherwise, you could use just one single Series with as many sequenceorders as you want.

Image #3

In the SpawnSequence of "Single Platform": I mean a succession of 3 instances of a solid object, using the three frames 0, 1 and 2 (see Image #1 at the bottom.)
Image #4

A double platform is simply like the single one, except it has two central instances (widest frame) in the middle, and has the two other frames (which I called edges) on the borders.

The following are the SpawnSequence groups I used so far are: single, double, triple, quadruple, quintuple, and decuple (10.) Image #5 shows an example of Double platform solid, involving 4 instances of the same solid object, just 3 frames as follows:
Image #5



An example of series: it actually goes down until SequenceOrder 23 or 24 (see the following and last Image #6 at the bottom.)
I will certainly update this article as this first version is typed in a rush, and I may even make a series to brake down all the steps, so that it can be easier to understand.
If you have any question then please don't hesitate!
Image #6