Tag Archive: progress


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 πŸ™‚

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 !)

Design a site like this with WordPress.com
Get started