Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

Dev Blog: Project Defender

Now that Wave 1 development kits are starting to arrive on doorsteps and riding the wave of motivation from an amazing //Build event. I am starting a thread on a project I have wanted to tackle for a while.

Project Defender:


Overview:
The goal is simple; Keep planets in your galaxy safe from waves of invading enemies. In full disclosure I have a loose game design planned, but there are still lots of mechanics to work out.

Timeline:
Keeping in the spirit of full disclosure; This project will progress slowly. Between a full-time job, traveling every week, and a pending move… Free time to work on this will be limited, as will my access to a device. However, I will be sure to update and monitor this thread for any questions as the project progresses.

End Goal:
The main goal is to have fun! During this project I am hoping to further my knowledge of developing for the device, my knowledge of Unity, and to share my development process and thoughts with this amazing community. So if you have any questions or feedback, feel free to post! Since this is also an UWP app I plan on trying to make a touch screen and Xbox variant.

I am ecstatic to begin this adventure with you all and be sure to stay tuned for the next update!
-Ryan

«1

Comments

  • Navigation Part 1 – Getting Ready For Movement

    Since I am more right brained, I wanted to try getting some of the technical issues out of the way first. One of the biggest items to tackle for Defender is navigation. Out of the box Unity does not have any systems to deal with pathfinding on sphere objects. Searching the asset store it seems like there were no pathfinding solutions that also made this easy. Some of the plugins could be made to work with a round object, but they were pretty heavy containing many features I did not need.

    Going back to the drawing board and remembering the whole point of this project is to push myself, I have decided to come up with my own system.

    3D Max is my friend:

    I do all my asset creation in 3D Studio Max. Knowing I had to create several planets I wanted to come up with a system that was easy to use and could work on non-perfect spheres for elevation changes.

    Placing Dummy/Gizmos:
    I decided to make a max script that could iterate through every vertex of my planet and if the conditions are met (vertex alpha value) then it would place a gizmo object at the vertex location. Once the gizmo was placed I then calculated a proper up direction based by averaging all normals of each face attached to that vertex. Getting the up direction is key for making sure the enemy is always rotated the right way.

    Cleaning things up:
    Once I have the gizmos generated for the path I now needed to go through and get proper naming on the gizmos so I can have a nice ordered array of transforms to move the enemies through in Unity. Once gizmos are generated the max script prompts you to pick the starting gizmo of the path and then runs through the gizmos and renames them in a way I can sort (i.e. pathA_001, pathA_002, etc..).

    In the end:
    I have an easy way to make an array of transforms to move enemies through in Unity. I chose to use vertex alpha to do this as I want to use vertex color for future use and I can still use 3D Max’s vertex painting tools to easily make a path. The gif below shows different stages of the max script doing it’s thing on temporary art with 3 different possible paths.

  • Thanks for documenting your journey for us. Good luck with the project.

  • Blue,
    Thank you for the kind words!

  • Navigation Part 2 – We Have Movement!

    Now that I have a nicely named list of transforms for enemies to move through. It is time to get it all working in Unity.

    XML for tweaking/balancing:
    I decided to use XML files from the start to control items like the enemy spawn rates, how many spawn per wave, wait time per wave, etc. This will make balancing easier in the future once the project is more complete:

    Building the Array:
    This was very straight forward. I tagged all nodes that belonged to each path to easily put them in the array (i.e. PathA, PathB, etc). There was one caveat, the names did not come in order as expected so I linked in the Linq library to easily sort the array in alphabetical order with one line of code:
    pathA = GameObject.FindGameObjectsWithTag("PathA").OrderBy(go => go.name).ToArray();

    Enemy Spawning:
    To spawn characters I have each enemy type placed in the scene not enabled. I then instantiate the correct enemy as a clone then destroy it when I reach the end of the path, this is where game logic will go later. I know instantiating and destroying causes more performance overhead and using a pool of pre-placed characters is better. So if performance becomes an issue I can look at this later.

    Some Randomization:
    Since I had three paths I simply have a function to randomly pick one of them, then load in the array of points for that path.

    Enemy Moving:
    Once I have spawned a character and have the path points I can now easily use two commands on the update loop for the enemy. The first one is moveTowards with a step that is multiplied by time delta and the characters move speed variable. The second, more tricker one is rotation; For this I am using the up vector for which way the character is standing up then getting a look at of the next point and manipulating the other two axis to transition to that.

    The End Result:
    I have a nice system to spawn as many waves as I want and an easy way to edit the wave amounts for balancing. The enemies also move smoothly along a chosen path of points built from my max scripts. Below is a gif showing items moving in Unity with temporary art:

  • I have one question. How do you set path for each enemy ?

  • Cool project! Thanks for posting updates.

  • @Fixus said:
    I have one question. How do you set path for each enemy ?

    Fixus,
    When I spawn the enemy I pick a random number between 1 and 4 (which results between 1 and 3 due to Unity's Random.Range being inclusive). I then assign it like so: if =1 then use pathA, if = 2 use pathB, if = 3 use pathC.

    Then I have two functions on the the planet
    GetPath(letter)
    I run this at the start function and have it setup so if it has already been generated return the generated result so I am not recalculating all the points every enemy spawn. This again just makes a nice sorted array of points for the player to iterate through (see post above).

    GetDistance(letter)
    I track the distance between each point and add them up. I plan to use this later as a normalized result vs the players total travel so I can see who is furthest along in the path for picking which enemy to shoot. Since sphere paths are not all the same distance. I always want to make sure I am shooting the furthest player if it is in range of the turret. This is also only generated once if it has not been generated before.

    Hopefully that helps answer your question, if not let me know!

  • @EgoAnt said:
    Cool project! Thanks for posting updates.

    Thank you kind sir! I cant wait to start getting to the art... This one will be tough with how many objects I want to have rendered at once.

  • Thanks for the answer. So as I understand you have predefined paths and you just pick one. I was wondering is this your solution or maybe you`re generating a path during enemy spawn

  • @Fixus said:
    Thanks for the answer. So as I understand you have predefined paths and you just pick one. I was wondering is this your solution or maybe you`re generating a path during enemy spawn

    Not generating during spawn as I am afraid that may become too expensive with the amount of enemies I want. They are all pre-generated. The workflow for this is outlined in the "Navigation Part 1 – Getting Ready For Movement" post.

    I took a picture and posted below on what the export looks like from max for reference.

  • Great job! Keep the updates coming. It's fun to follow along.

  • @BluePotato said:
    Great job! Keep the updates coming. It's fun to follow along.

    Blue,
    Thank you again for the kind words... They are grease for the ole wheels. Now if only there was more time in the day :)

  • Turrets Part 1- Let The Firing Begin!

    For this design I am planning to have four tower types: Direct, Poison, Area of Effect, and Slow Down. Each tower type can be upgraded to four different levels and stats will increase accordingly with visuals to match. Like most tower defense games each tower type will have pluses and minuses and it will take a crafty combo of all them with proper placement to defeat the waves.

    Since direct seemed to be the easiest to do of the group I am starting with it.

    Direct Hit Tower:

    Setup:
    For the temporary art model I have it split into 3 parts: base, turret, and projectile. I have it parented in this order: projectile is a child of turret and turret is a child of base. I have the projectile not active and just use it to instantiate new projectiles.

    Getting Objects In Range:
    This was very straightforward to setup as I did not want to over think it. I basically used a sphere collider with triggered enabled and add players that enter to an array (if they are not already in the array). Then when they exit I remove them from the array (if they haven’t already been removed). From there I just target the first index of the array (if it is not null) as it should always be the leading enemy for now. The key is enemies now need a rigid body to set off the tower collider, it is important that you check the “Is Kinematic” option. If you do not then physics will start taking over your enemy movement. One last step is setting up the turret to always look at the enemy with some axis locked, this was much harder than thought seeing as a tower can be placed around the sphere. Luckily there are extremely smart people that work here that came by and taught me how to cross a bunch of dot products to get the result I wanted.

    Projectile:
    I have a float value for how often this tower can fire. Once that cool down variable is reached and enemy is in range then I instantiate my projectile model and move it towards the center of the enemy’s bounding box. Once the transform.position of the projectile match the center of the enemy’s bounding box I send a message to the enemy with the projectile's damage amount and then destroy the cloned projectile object.

    Sending Hit Message To Enemy:
    As part of this process I now have to have a health float variable for each enemy type. Then I have a simple function that applies damage to the enemy (through the projectile send message). I also added a simple check to see if the health is below zero to destroy the enemy and do some house keeping.

    In the end:
    Everything works and I can easily scale this to the upgraded towers by changing the collider size, damage amount, and cool down time! I have added the obligatory over compressed gif of temporary art to see it in action!

  • Turrets Part 2 – Sidetracked

    After spending too much time trying to debug and track enemies to make sure my projectile is doing the behavior I expected. I decided now was a good time to add a health bar as a visual feedback element. This will help to ensure things are acting right as I get into more complicated towers like poison and the area of effect.

    3D Elements Are Your Friend:
    A big aspect of the HoloLens is that you are now IN the 3D world! So naturally I wanted health bars that are 3d and can be seen from all angles. For this setup I just made 10 small boxes parented to my temporary enemy mesh I can easily flag on/off. This is not the most performant solution as it means many more game objects are now in my scene(enemy count * 10). As I start to optimize I will have 10 different meshes to flag between with the right amount of bars, taking the object count from 10 to 1 in the worst case scenario.

    Hooking It Up:
    No real magic is happening here. I have a function I call when I damage the enemy to update the health bar. In this function I normalize the health of the enemy then hide bars that don’t match the health % (why I chose 10 bars). At certain points I change the colors from green to yellow and yellow to red.

    A Little Effort Goes A Long Way:
    By setting this up I now have a nice visual way to debug each enemy’s health to make sure everything is working properly. In the gif below I lowered the turret’s damage and increased the firing rate to show this all working.

  • Tower defense on a sphere. That's perfect for the Hololens platform! The player will have to move around the room to see the enemies and towers. Really great concept. Did you consider having the health bars always turn to face the player so they can always see the enemy health remaining, even if viewing the enemy from the side?

  • @BluePotato said:
    Tower defense on a sphere. That's perfect for the Hololens platform! The player will have to move around the room to see the enemies and towers. Really great concept. Did you consider having the health bars always turn to face the player so they can always see the enemy health remaining, even if viewing the enemy from the side?

    Blue,
    Thank you as always for participating :). As a huge fan of tower defense games I thought it would be really cool to transform it into a mechanic never done before. For controls it will be a combo of walking around or simply dragging to spin the world around.

    For the health I do have plans to add it to the wish list, but with the little buggers moving so fast I think it may be too much going on.. also since I will have quite a few of these buggers it seems like updating the health rotation every frame might take a bit of a performance hit which I will need to save for other places.

  • Many TD games don't have health bars for enemies. Or maybe just for bosses.

  • @BluePotato said:
    Many TD games don't have health bars for enemies. Or maybe just for bosses.

    This is true :) I will have to just see how it looks once the waves really start coming in! I feel like most did not have bars as it was to save on performance. Since most TDs I have played are 2d sprites the stacking can get very expensive and distracting. That is one fun element about developing for the HoloLens, try everything! Rules that have traditionally applied to design, do not anymore so there are happy mistakes to be discovered everywhere.

  • Turrets Part 3 – Poisoned

    It has been a busy work schedule the past couple of days however finally got time to sit down and setup the poison towers.

    Damage Over Time:
    The poison tower from an engineering standpoint is very close to the direct tower. From a design aspect when the enemy is hit by a bullet it does no instant damage, but instead drains x health over x time. The poison tower will do more overall damage than the direct tower to enemies at each level. However, it will come at the down side of cost and time it takes for the damage to be applied.

    Getting It Working:
    Since the engineering side is very close to direct, there is not much that had to be done here. I now added a poison tracking system to my enemy health script. If a poison projectile hits the enemy, then I trigger this state and apply a visual to let you know the enemy is being damaged. Once the time is up I stop apply my poison damage.

  • MondayMonday admin
    edited April 2016

    Turrets Part 3 – Let’s Make A Splash

    The next turret on the task list was the area of effect turret. Leveraging from the other turrets same “tracking system” all I had to do was change around the projectile behavior.

    Setting Up the Projectile:
    The first think I wanted to change about the projectile is its path to the enemy. I thought adding a nice arc in the upward direction would add a nice effect when viewing the world from different directions and it seemed more “rocketish”. To do this I added a max height variable and then added some sin and pi math into the movement equation.

    The Area Of Effect:
    Once the projectile reaches its destination I do area of effect by spawning a sphere collider (radius will change size based on tower level). Once the sphere collider is spawned I find all enemies inside the collider. I then take the sphere radius and do some math for fall off damage by taking the mid location of the sphere and finding the distance the enemy is from that.

    In the spirit of gifs and temp art :smile:

  • Turrets Part 4 – Time To Slow it Down:

    The last tower type I have in my design plans is a slowdown/freeze tower. Building on the tower script now hooked up through enums I was able to leverage most my work. The only thing that needed to change was the projectile behavior when it reaches the destination point.

    Setting Up The Slow Down Projectile:
    Once the projectile reaches its final destination I spawn a sphere collider. The radius for this collider will change depending on the tower level. Upon the collider spawn I grab all the enemies currently inside of it. Then start tracking as new ones enter or exit. When they enter I multiply their speed by a fraction (that will also change per tower level) and when they exit I change them back to their original speed. The collider will last for x time then disappear.

    Below is an example gif with temp art with the system setup and working!

  • Let the Fun Begin!

    With most of the harder (for me) technical challenges out of the way. It is time to get to the fun stuff… ART!
    After going through several iterations of what direction the art should go I decided to write down some important objectives and go from there.

    Planning:

    • Performance: There will be lots of objects between the enemies, towers, and extra polish that all need to be fully dynamic. As outlined in the documentation, maintaining 60FPS is critical for user enjoyment.
    • Time: There is a long laundry list of assets to create. With myself being the only developer on the project I needed to use a more simplistic style in order to finish this project sometime this decade.
    • Color Values: Since holograms are additive into your surroundings, meaning black is not visible and white being completely visible. The color values need to be bright to be able to see them clearly.

    The Decision:
    After much trial and error, I have decided to use a popular style currently used in indie games: The Polygonal Faceted Look. This style meets all my requirements above:

    • I can use almost no textures, saving time and performance.
    • The look feeds well into lower poly models, saving performance.
    • Bright, cheerful colors work really well matching the need for bright color values.

    Below is the start of my first planet which is forest themed, still lots to add but it is progress! There will be several different themes for each planet based on real world inspiration.

    Break Down on how this was achieved through a shader coming soon.

  • So good! You're making great progress. I'm quite fond of the "Polygonal Faceted Look." Are those stars going to appear in 3D space around the planets?

  • Wow keep going it is awesome.
  • MondayMonday admin
    edited April 2016

    @BluePotato and @mat9054 Thank you!!! It is the fun part of a project for me :)

    @BluePotato the stars are particles in 3d space they will get more loving as time goes on :)

  • It Is All About The Shaders!

    For 95% of the art in this scene I plan on using one shader built off the LambertConfigurable provided in the HoloToolkit. It was the most logical base as much of the performance work was already done. I just had to add on top of it with keeping in mind performance.

    The Land of # if and # endIf:
    If you have had the chance to explore the shader at all, you will see there are two key elements: the .shader file and the .cginc file. The shader file is just for setting up key properties that will interface into the .cginc. When adding to the shader I was very careful on the new properties I wanted to expose using the same existing format. Also in the .cginc file I was very careful on making sure I wrap my new code in in # if statements. This is KEY for maintaining the performance, if I do not want to use any of these new properties the shader will continue to compile to the smallest, most performant format possible.

    Starting With The Base Shader:
    We all have to start somewhere and this is what my planet looked like using the unedited lambert shader provided with the toolkit with one directional light in the scene.

    Adding Rim Lighting:
    Being blown away with the visuals Mario Galaxies achieved on the Wii, the key behind giving the planets so much life was a nice rim lit shader. Wanting to mimic this style I added two new properties to the .shader file, _RimColor and _RimPow. The _RimColor will control the color addition around the edges. The _RimPow will control the fall off between the _Color (main color) and _RimColor. Then in the .cginc I add all the inputs in the vertex pass and the math in the pixel pass to make it work properly. With this setup I have lots of freedom per material to manipulate the final look.

    Adding Vertex Colors:
    One last thing I wanted to add to the shader to give it more “depth” is vertex colors. I paint these colors per object in 3DMax. Currently I am only using shades of grey to tint the material’s main color. In theory I can use one shader and material for everything in the scene by coloring each vert with actual color values. However, I opted out of this as coloring per vertex and deciding later I wanted to tweak color values would lead to a massive time sync / overhaul. For this I simply added a “Use vertex color” property bool to the shader. In the .cginc I multiply the vertex color by the main color. This does mean I find myself segmenting mesh more for shading properly, but rendering vertices is cheaper in most cases than adding extra passes.

    The End Result:
    I have a very performant and functional shader for most of the objects in my scene. By setting up a tweakable rim color and power. I can now adjust different materials to feel like real world materials (wood, metal, grass, etc).

  • Hammer Time With Movement

    I had some time over the weekend to setup the empty tower platforms with a little art polish.

    Gaze Manager
    First thing I hooked up was the gaze manager. Since I wanted to start moving the planet around I needed to provide user feedback on where you were looking via a cursor. The Gaze Manager in the Holotoolkit makes this extremely easy! All I really had to so was add the script to the cursor I made and be careful about tagging collision objects I wanted the cursor to display on.

    One Platform To Rule Them All
    Since the Hololens uses UWP apps. My goal is to make this work on the HoloLens, PC, and Xbox One. For my controls I am using a script a talented co-worker wrote that takes Unity's default event handling system for each input method and makes it simple, now: on enter, on exit, click, and drag... are universal between the systems. I am using this input manager to control drag spinning the planet on drag/click move and also detecting when you are gazing and tapping/mouse clicking on the tower platforms.

    Setting Up The Build Platforms
    Since my next step is making the final art for the towers and the menu to build the towers. I needed to setup where the tower locations are going to be. I did this by placing more gizmos/dummies in 3DMax at each desired platform location then in the planet's start function I instantiate my tower prefab (the prefab will contain all towers, menus, etc) to each transform gizmo location I placed in 3D Max.

    The Small Details Can Provide Useful Feedback
    One amazing thing about designing for the Hololens is that the smallest polish can provide amazing results in 3D space. For the platforms I wanted to provide more feedback then just changing the cursor color. So I decided to add some hammers as an icon to the empty platforms. These hammers will animate as you enter over the platform and then go back to rest position when you gaze/move off the platforms. Eventually I will have them "hammering" when they are building the tower you have selected through the menu.

    Below is a progress update of all the work done over the weekend, be sure to full screen in 1080p for best results.:

  • Direct Tower Level 1

    With the platforms setup the next tasks is creating more polished art for the first levels of each tower. The plan is to make the towers look "meaner" and technologically advanced as they gain higher levels.

    The first one is the direct tower:

  • This is looking pretty cool. Do you have a Hololens with which you can do a video capture? The contrast is nice with the black background, however I am curious how it will look in an AR environment. That's one of the interesting things with AR design is that the environment with which things are viewed are less controlled.

  • If you don't have a HoloLens and want me to try it out and capture some video with mine, let me know. We can figure out a way to make it happen

Sign In or Register to comment.