Category: General


The Students say Hi!

Hello!

Johan Terink and me (Koen Deetman) are two students that are doing an internship at Code Noctis.

Johan Terink is the programmer of this duo.
If it comes to technical questions, he’s destined to find an answer to them!
He’s also controlling the basics of game design.

Koen is the designer in this duo.
He’s the one that’s highly motivated for every new project. Besides game design he’s a self taught artist and is able to do a lot of work on that part as well.

We are encouraged to create our own concept and fold that into a game for the mac and pc and if there is time, iPad and iPhone.

We will keep track of the game’s development and will post an update now and then about our progress.

Switched from MonoDevelop to Visual Studio 2011

D1c1

After working a while with MonoDevelop I got tiered of the instability of it on the mac. Also the irregular behavior of the Intellisense got annoying and more of a distraction  then actually be helpful. Because the Intellisense really is a nice helper to point out what arguments and types your functions expect and prevents a lot of typo’s I wanted to see how it works out in Visual Studio 2011 (VS). Next to that Ive heard a great good deal about ReSharper from Jetbrains.

Time to dust off my Parallels virtual and install VS. It took me quite a while to get through all the settings of both VS and ReSharper, but let me tell you , it’s really worth it. You can completely tell it what your coding style is. From the globals like using two spaces in stead of tabs for indentation, not putting curly braces on a new line, to the minor details like adding a space after your comma’s.

I started messing around with Unity using UnityScript since thats a really easy entry point especially if you already feel comfortable with Javascript. Though after writing some script, having a good feeling about Unity and wanting to do things right, I made the decision to switch over to C#. Since I work on a daily basis with the highly dynamic language called Ruby, I still have to wrap my mind around the staticness of C#. Though now I’ve been working with it for about a month, I must say i really do like it. Even though at first C# seems quite static, you actually can make it dynamic as well with the use of lambda’s and the like.

The Intellisense of VS is awesome ! It works really well and is an invaluable tool, but the things that ReSharper showed me and thought me is simply amazing. It’s like having your own personal pair programmer sitting right next to you all the time. It tells you if your code is good, if you actually use the code you create. It even helps you reformat your code to make it more robust and can detect more advance things. An example that blew me out of the field was with an iteration I was working on which went over a List. ReSharper offered a suggestion to use Linq and went right ahead rewriting the whole iteration into a Linq statement. This is great for teaching you new stuff !

 

P.S.

As I am quite hyped about this I saw that JetBrains also created RubyMine, which is a Ruby IDE. We normally work with Textmate but it seems development has ceased on it and so we where already looking for an other tool. RubyMine is a very nice tool as well and we use it now on a daily basis. The only “negative” thing about it is that it’s a Java based program thus a resource hog and no native look and feel.

 

Unity3d 3.4 Mono develop and dark themes

With the latest Unity3d 3.4 update they have set MonoDevelop as default. I’m going to give it a try and compare how the experience is working with mono develop compared to my usual textmate. One thing the compels me is the Intellisence which might come in handy and save me a lot of unity reference lookups to see what the right types are for the method call. Though before I could start using Mono Develop I had to get rid of the whiteness ! As mono develop uses GTK+ you should be able to just drop in a gtk theme and be fine. Alas it was not as easy as this :/

You can download some dark themes I found including my howto in one package here : http://dl.dropbox.com/u/1723477/darkmono.zip

DarkMono

After some experimenting I found something that works fairly well for me. Follow along if you are interested 😀

 

Download a GTK+ theme to your liking. You can use sites like : http://gnome-look.org/
Make a new directory in your homedir called .themes : mkdir ~/.themes
Extract your downloaded themes to this directory.

After that you :

– Start Mono develop

– select visual style -> Interface theme ->  clear looks black blue

– select text editor -> syntax highlighting -> irBlack

– Quit Mono develop

 

Then either backup or remove this directory and file

mkdir ~/default_monotheme
sudo mv /Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Versions/2.6.7/share/themes/ ~/default_monotheme
mv /Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Versions/2.6.7/etc/gtk-2.0/gtkrc ~/default_monotheme

 

Then start mono develop again, and now your eyes are at ease 🙂
Happy coding everyone !

An other weekend passed, so an other update is in order 🙂

The planning for this weekend was to add an other magic effect, a targeting system, GUI element reflecting the target and fix some of the animations.

Targeting System :

As it is now we can freely shoot fireballs and hope we hit our target. But for our next skill we actually need to focus on a target, thus it was time to create a nice targeting system. This actually took several tries to get it right, or at least, we hope it’s right now 😉

The first iteration of the target system worked like this : As our characters have a FieldOfView that helps with detecting if an object can actually be seen by the character I thought this would be a nice point to start with. Though pretty soon I found out that you can only check of a certain gameObject’s position is within the FieldOfView vertex. To prevent checking of all objects I made a matching mesh collision so that we could refine the scope of objects to check. When an object collides we then check if the object is within the FieldOfView vertex so we know that we can actually see it as well. For example a target around a corner would generate a collision but we would not be able to see it. So if these conditions where true we add the object to a Potential Targets Array which we then could use in our targeting system. The problem with this turned out to be the FieldOfView itself ! For example when we have a character that was bigger then our eye sight it would obscure our vision. Which of course is intended but also meant that when we checked of that character was in our FieldOfView we got irregular results as we could not see the objects front if we where behind him and vice versa.

The second iteration of the target system : Abandoning this tactic I went for a much simpler one where we now just shoot a RayCast line from the target to the source in our collision field. If the RayCast actually hits the target then obviously we can see him and add it to the potential target list. After this was done it was a simple matter of binding the Tab key to a script that cycled through all our potent targets in the array move a targeting ring underneath the selected target.

 

GUI Element for the selected target : Now that we have a target selected it would be nice to reflect that not only by using a targeting ring but also in the GUI. I wanted to create the classical item where you see a ring containing the animation of  the head of your target, so you can see its facial expression when tossing that fireball at him ! Next to that the defaults like name and health bar. The name and health bar where pretty straight forward and nothing special. It took a bit more to get the characters head in there though 🙂 After some research I found out that you could use a RenderTexture, which is a unity pro feature. This texture can display for example the image of a camera bound to it. So I set up a new dynamic camera that would attach itself right in front of the face of our selected character and send it’s feed to the render texture which is placed inside the GUI target ring. This worked as a charm but you would see everything behind the target as well. Setting the camera depth to a very small value made sure that everything behind the head turned into a solid color , which you could then make transparent. There you go, A live feed of your targets head in the GUI 🙂

 

The new spell :

Images

Of course you cannot have a mage without the classic Magic Missle ! In stead of just creating a particle effect that zips in a beeline from caster to target I wanted it to be a bit more dynamic, chaotic and in the future make them more controlled. Now that we do have a targeting system we can select our target and prepare our missiles. The first step is getting a beeline from our caster to the target, get the distance between them and divide that by a reasonable amount so you get equal chunks. Then I wanted to deviate randomly some points off that path. Wes helped me with the 3d vertex math of placing the points randomly among the X and Z axis. After this was done I used iTween to give it the missle, the path and the final target. As each missile will calculate its own random path on instantiation you get a very nice chaotic effect when shooting for example a barrage of 5 magic missiles 🙂

 

Fixing some of the animations : Currently when you are walking around and start casting a fireball the casting animation would take over from walking and you’d slide forward until you are done casting and the walking animation takes over again. This really looks nasty. In stead of needing an other animation that makes the character walk and cast unity allows you to actually combine the two separate animations ! First you have to put the animations into layers and group those on mutual exclusiveness. For example idle, walk , run will be layer 0 and casting in layer 1. Then you detect if you are moving and want to cast. If this is the case you’ll tell the casting animation that it may only use the animations from the spine of on. This way the legs are being left alone. Now you can blend the two animations creating a walking casting character !

 

Finally:

As I’m getting more and more to terms with unity and the scripting I wanted to clean up all of the scripts made before. Making sure to abide by the conventions of naming classes, variables and methods. Also the project’s hierarchy was becoming quite messy so we cleaned that up as well.

As usual you can find an updated progress of the current state here 🙂

Another weekend, another Unity hackathon. One of the nice thingies I created today is a simple script that tells me what object my mouse is pointing at.
The source code for Physics.Raycast offers examples that help with mouse-to-screen conversion and ray casting, but they don’t wrap it up into a plug ‘n play script.
This one should be just that.

I wonder if this is the right way to handle this or if there is a built-in function to do it, which I overlooked.

I’ve also attached a screenshot and demo level I’ve dubbed Neon City. It uses self-illuminated cylinders with a black/white texture for the borders. There are stacks of boxes with a brushed steel texture that uses the Reflective/Parallax Diffuse shader for shininess and for a reflection of the sky texture. Either way, it was fun playing around with baking lightmaps and seeing what you can do with Beast. It’s really, really easy to setup a scene that seems to have small lights every everywhere, even though there is only a single Directional light in the entire scene.

Another fun thing Gerard and me discovered today is how easy it is to place a camera in the scene and have it render its output onto a plane somewhere else, to create a security camera + monitor system.

One thing that bugged me about earlier demos is that almost every edge in the game appeared jagged instead of being smoothed by anti-aliasing. In order to render real-time shadows from point lights such as fireballs, the rendering path needs to use Deferred Lighting. The trade-off, as documented on the Unity3D site, is that there is no anti-aliasing in Deferred Lighting mode. The default Forward Rendering mode gives you anti-aliasing, but no real-time shadows from Spot/Point lights. Only from one Directional light.

Unity is very helpful that it lets you know that only directional lights have shadows in forward rendering, but according to Warwick Allison, you can create your own shader with the fullforwardshadows setting to enable shadows on your surface. After an hour or so searching and surfing, I did not manage to find a package with shaders that add this behavior to the default shaders, so I guess I’m looking for something that either people don’t find too bothersome or that’s too hard to do. For now, I hope that a future version of Unity will fix this.

Anyway, here’s the source code for the detector script and below that is a screenshot of demo 7.


#pragma strict;

/***********************************************************************************************

Usage example:

  public var cam : Camera;
  public var text : GUIText;

  // If the mouse points at a an object, display the name of that object on screen.
  function Update () {
    var obj = MousePointerObjectDetector.Detect(cam);
    if (obj) {
      text.text = "Hit: " + obj.name;
    } else {
      text.text = "No hit";
    }
  }

***********************************************************************************************/

// For the camera, return the Transform of the object that is pointed at by the camera.
// Returns null if nothing is pointed at.
class MousePointerObjectDetector {
  public static function Detect(camera : Camera) {
    var pos : Vector3 = Input.mousePosition;
    var ray : Ray = camera.ScreenPointToRay (pos);
    var hit : RaycastHit;
    if (Physics.Raycast (ray.origin, ray.direction, hit)) {
        return hit.collider.transform;
    } else {
      return null;
    }
  }
}

Screenshot of demo 7

Exploring unity3d, second weekend

My plan for this second weekend on exploration in Unity3d : Give’m goblins some behavior !

Last weekend I basically had a plane with some Goblins standing statically around doing their best imitation of a sitting duck and looking funny at you. As a player we could could walk around and toss fireballs at them. But hey that’s not much of a challenge now is it ?

Time to add some life to them. The first thing I wanted to give the Goblins was some way of moving around. It would be nice if they could wander around and even better, to walk a patrol route ! So after messing around with some animation code, dumping some gameObjects as patrol nodes, etc, they where able to walk a patrol…..as long as nothing was in their way ! I would need to give them a sense of their surrounding to get around obstacles between their path. Pathfinding it is then.

In the asset store I found exactly what I was looking for : Simple Path by Alex Kring. After watching the video and reading the documentation I started with the implementation of it. This could not be simpler ! In no time I had my Goblins wandering around and patrolling all over the place 🙂 In the demo’s that came with the plugin i found that you could even let objects chase an other one. Perfect !

Looking at the scene now shows a bit more life. Though the goblins now are horrible failing at playing sitting ducks, we as a player have a bit of a harder time to shoot them down with our fireballs 🙂

Next up :

Give the patrolling and wandering goblins something to look for, obviously the Player for now. I looked for a Field of View tool in the Asset Store and … was pleasantly surprised with : Fov Mesh Maker by Hyungseok Seo. The documentation is quite hard to read, but the author did his utmost best to write it in English. The examples provided with the plugin are quite well and gives you all the information that you need to work with it.

After messing around a bit we now have some goblins with vision ! I guess before they had some freaky third eye or where psychic. Either way, now they can actually see where they are going 🙂

By now the scene evolved to a bunch of goblins that are roaming around, patrolling and looking for the Player. If they spot the player, they start casing him for ever and ever more.

Evolve the scene and add some gameplay !

I tried to make the scene a bit more interesting by adding a room in the middle of it. Due to the placement of the room we have an outer ring that we will now call “corridor”. The room has one entrance and in the room I put a cylinder with a glowing golden ball. This is what the goblins will try to protect.

With these elements in place we can now work on more behavior code : The player has to avoid detection by the patrolling goblin in the corridor. sneak into the room and get to the golden ball without being detected. If one of the goblins in the room spots the player, he should run for the alarm gong and rouse all other guards in the room so they can join him in chasing the player.

Building the Alert mechanism was quite fun indeed 🙂 On google i searched for a free 3d model of a chinese gong that could function as a nice prob. After a bit of searching around I found a really nice 3d studio model. Upon importing the model my scene grinded to a halt. The model has _so many_ polygons that basically the GPU turned nuclear 🙂 I either had to look for a low polygon one or somehow fix this one. Searching google for this problem i found a solution \o/

I should be reducing the amount of polygons the object. To accomplish this I used MeshLab. Now the model was nice at 7500 tris ! Awesome stuff we have an alert gong prob standing ready for a goblin to bang his head against , or _if_ its smart enough he’ll use one of his brethren as a battle ram 😀

Binding the guards to the alert Gong should help us in the level building. Basically you would like to just drop in the alert gong and your prefab guards should be automatically registered. To accomplish this I added a boolean to the goblin prefabs isGuard. The gong would have a big collision box on it that is setup to act as a trigger. Now make the box as big as the area you want to alert gong to cover. Any guard in the collission box will be registered by the alarm. When a guard sees the player he will make a run for the gong and sound the alarm ! The alarm prob monitors if it is sounding and if so it will send a message to all the registered guards to start chasing the player.

With all this in place we had some basic gameplay mechanics and the clock stroke 01:00 sunday night…. Quite happy with the progress i could finally head to bed and have some well deserved sleep , finally ! (i can never sleep well when working on stuff so friday and saterday night the sleep did not come…)

You can View the progress of last weekend just to get an idea of the state i was at before i stared to continue this weekend.

And here you can view the results of this weekend !

(use 1 to shoot a fireball !)

Day two with Unity3D

This morning I set out to expand the last demo I created yesterday. The result is Demo4.

Demo4

20110711-di13npqhrbek9j52ffs2x1wepn.png

20110711-d522ud152bnw3snkqtrydy2s3j.png

In Demo3, the fireballs were duplicates of the same tree of objects. In demo4, they are in a new prefab that replaces the old fireballs. This proved useful when I wanted to update the look, feel and behavior of all fireballs.

The behavior change to the fireballs is in how they handle their patrol route. Demo3 remembered their starting point and I supplied a Vector3 with the X/Y/Z coordinates they would move to. Once they reached their goal, they would compare their position with their starting point and endpoint and they would pick the one they were not at to move to next. This worked, but it was limited and it resulted in fireballs attacking walls when I duplicated my room and moved the copy 10 units to the side. Oops.

So the Demo4 version of the fireball patrol route uses waypoints for navigation. The waypoints are instances of a simple PatrolNode prefab with an attached script called DisableMeshRendererOnAwake, to show the nodes while developing, but not when playing.

The fireball patrol script exposes a collection of GameObjects and the index for the current target. Each PatrolNode added to the collection is moved to in order. I ensure constant movement speed by using Vector3.ClampMagnitude on a diff between the current and target node position and multiplying it with Time.deltaTime to scale it down based on frame render time.

Once the fireball patrol code was done, I could easily add bigger patrol routes, so I did and most fireballs now chase after each other in the room.

The number of rooms I increased one-by-one until there were four.

Room one is the original room of Demo3, but the fireballs patrol in a square instead of up and down a line. There’s a corridor to room two, which is identical to room one except that there are no spotlights. The fireballs are stronger point light sources now, so they illuminate the room rather well. Next is a connection to room 3, which has no more inner wall and no spotlights and has each fireball patrol around its own pillar. Next is a connection to room four.

Room four is 20×20 instead of the 10×10 of the other rooms, but it has a 10×10 area in the center that’s a copy of room three except that there are no walls. The walls are half height and placed at the edges. Instead the floor is covered in grass and most of the room looks up to a skybox.

Since all solid objects are basically cubes that have been stretched to non-cube shapes, I’m making a new Material for each aspect ratio of wall or pillar I need. I’m sure there’s a better way to do it. I could look at turning one big 20×0.1×3 wall into a collection of 0.1×0.1×0.1 cubes and stacking them. Since the texture is seamless, this should work well, but there’d be a lot of different objects and lots of textures on sides you can’t see. It seems rather inefficient. The alternative is to figure out how I can create a texture that fits my wall’s dimensions exactly.

Demo5

20110711-bjx1xuj2kus41r6bxa5bpnh2ad.png

Tonight, I created Demo5 to get a better grasp on collisions and the physics model. It’s a simple bowling game built on top of the roof of Demo4 🙂

The player holds (via a FixedJoint) a heavy sphere, the ball. The BreakVelocity and BreakTorque are set to infinite, so the ball will stay glued to the player.

The player has an Update function that checks Input.GetButton(“Fire1”) to see if the left mouse button or Ctrl is pressed. If so, it starts adding Time.deltaTime to a counter and the ball is forced to face the same way as the player. Once the button is released, the square root of the counter value is multiplied with an arbitrary value of 300 and applied as forward force on the ball. The ball’s BreakVelocity and BreakTorque are set to 0, so the ball immediately snaps loose and is propelled in the direction the player is looking.

The pins are instances of a simple cylinder prefab. They have a script that checks if their rotation is still (0,0,0). If any of the dimensions change more than 0.5 degrees, assume the pin has fallen and marke it as not standing.

There’s a GUIText element in the top left corner. Because all pins have been tagged with ‘Pin’, I can simply use GameObject.FindGameObjectsWithTag(“Pin”) to find all pins and check if they are still standing. Count the standing ones and display it in the GUIText.

The thing that took me longest to figure out was which collision detection method to use for these objects. I read through the docs a bit and it looked like ContinuousDynamic was the best option, as it checked against just about everything. Pins and ball used it, but the ball just bounced off the pin without making it move a hair. I lifted the ball in the air above the pin to drop it, and it did push the pin over. After an hour of fiddling and trying to write custom OnCollisionEnter() handlers I started flippiing the collision detection method and found that Continuous did what I wanted without requiring scripts. Lesson learned.

Fiddling with mass and drag taught me that a ball does not necessarily have to keep rolling forever.

The player is still set to be Kinematic, so it is not affected by physics at all. This also seems to mean that it does not make a pin fall over when the player pushes against the pin. Disabling Kinematic turns the standard FPS Controller’s jump action into a jump that keeps going on forever. Not quite what I intended.

Random lessons learned

  • Prefabs are very useful to base repeatable objects on, it makes it so much easier to change them all later on.
  • Using empty GameObjects is a very useful method for grouping objects.
  • Using objects as nodes for defining patrol routes beats manually typing in coordinates: they move along when duplicating a room.
  • Abusing cubes to create walls is easy to get results, but it’s not the prettiest solution when using a one-sided texture that’s repeated on each side of the ‘cube’.
  • The physics system in Unity3D is nice, but it takes a while to grasp the subtleties.

And that’s it for today. Perhaps I’ll create more demos during the week at night. Otherwise next weekend is likely going to be another hackfest with Gerard. He’s making progress on his demos, (though I need to bug him about posting his demos here) so it’s not going to be long before we’ll start working on tech demos/tools that can be useful for our first real game.

My first day with Unity3D

Today I sat down for my first day of Unity3D. Gerard was nearby to answer questions, but since he was working on expanding his own demo, I looked up more things than I asked him. By the end of the day we were helping each other troubleshoot our problems, so I guess I learned a couple of things 🙂

Demo 1

20110711-q8qy8ccr73eccs39mykiujxi22.png

 

This is a room built out of cubes that have been stretched and textured. I created textures using FilterForge. The construction worker guy comes with the 3rd Person Controller created by Unity, but his reaction is a bit iffy.

The fireball is two particle emitters inside an empty GameObject container that handles global positioning and movement. It does not cast light, but it does do collision detection while moving. Earlier versions of the fireball calculated the new position for the fireball each frame and set the transform.position instead of issuing a collision-detection Move order. Adding a CharacterController and replacing my Lerp-based transform with a Move order did the trick. The code also became a lot shorter.

There are Spotlights in the four corners of the room and an inner wall and pillar to see the effect of dynamic and static lights on real-time shadows. One thing to remember here is that the Rendering Path needs to be set to Deferred Lighting, otherwise only Directional Lights can cast shadows. Since I want to create mainly indoor locations (dungeon crawlers don’t have windows or sunlight) this was kind of useful to figure out.

Demo 2

20110711-pt1mxrinyxtyg165sgtxj4kj2c.png

 

I got annoyed with the iffy controls, so I tried to do something different: a first-person view with mouselook.

I generated some more textures with FilterForge and started looking into the available shaders for Materials. The ceiling is shaded with a Parallax Diffuse, which uses a base texture, a Normal Map and a Height Map that were all generated with FilterForge.

There are now four fireballs that patrol through the room and four pillars. The spotlights in the corners have been moved and re-oriented. All of this creates a nice interplay of shadows.

The new floor texture is also created using FilterForge.

I’m not quite happy with the fireballs: the smoke’s billboard shows as squares against a bad backlight, which is ugly.

Demo 3

20110711-nrg95aba14iirt6d8en4k7wte.png

 

This demo changes the fireballs to use the Particles/Additive (Soft) shader instead of the ~Additive-Multiply shader for both the flames and the smoke. No more billboards! I also tweaked the texture, number and size of particles for fire and smoke to give a nicer look. Enabling Simulate in Worldspace for the Particle Emitter makes the flames trail after the moving fireball.

I’m not quite happy with the bricks: compared to the other textures they look a bit bland and poorly stretched.

Conclusion

All in all this was a very productive first day. I learned the basic workflow of how to create Game Objects, how collision is handled and how to write my own scripts and make them run each frame. Before today, I knew nothing of shaders and lighting/shading. Now I at least understand what they’re about and how to use them.

Hello World

Mortals of this world, all tremble in fear!
Code Noctis is here.

(a.k.a. Hello, world!)

You can find us on :

We also have an about page where you can find a bit more about us.

Design a site like this with WordPress.com
Get started