Diablo-style game in Unity

I’m mostly a 3D artist who has done some HTML and PHP scripting, so please bare with me here.

Currently, I am looking to replicate the game Diablo within Unity. This is for a college course and I have about 6 more weeks to complete it. It does not have to be fully-functional or anywhere near complete; I simply need to prove I got the system to work and that a full game could be built of the basic premise.

These are my goals:

  1. To create a point-and-click navigation system.
  2. To create a working inventory system that allows for the character to pick up armor and weapons off the ground, keep them in a “pouch” or equip them to his character (at which point the character will a new weapon, etc)
  3. A working stat system that displays the characters health, strength, etc. based on a Dungeons and Dragons-style health system.

I’m not asking for hand outs or free code, just simply a point in the right direction. I understand this is an ambitious project and I probably will not and most certainly cannot achieve all of these things. I am willing to sacrifice the point-and-click system in favor of using the control scheme given in the 3D Platformer project if necessary. Most important to me is creating a HUD that is linked to an inventory system that can keep and add items that the player clicks on and then picks up in the world.

I’m also curious what code statements one would use to specify keys. For example, to access the inventory system, the player should press “i” on their keyboards in order to bring up and hide the GUI.

Any help is appreciated. Books, links to tutorials, whatever. Just get me set in the right direction. I’m a little adverse to coding on this scale so I’m not sure where to start, but once I get in there I should be able to get a firm grasp on what’s up.

You got my interest by mentioning Diablo :stuck_out_tongue:

Everything your asking for is already out there, you just need to find it :wink:

Google is your friend
So is the forum search http://forum.unity3d.com/search.php
and Unity answer search http://answers.unity3d.com/

I know of 2 existing inventory systems:
http://forum.unity3d.com/viewtopic.php?t=46222&start=0&postdays=0&postorder=asc&highlight=
http://unitytutorials.com/unity3d_inventory.html

Can try these sites for the rest :stuck_out_tongue:

http://www.forum.unity3d.com
http://www.answers.unity3d.com
http://unity3d.com/support/resources/
http://unity3d.com/support/documentation/
http://www.unitylabs.net
http://www.reddit.com/r/unity_tutorials/
http://www.reddit.com/r/unity_blogs/
http://www.reddit.com/r/unity_sites/

http://www.vimeo.com/unity3d

http://www.learnmesilly.com/
http://unity-tutorials.com/
http://unitytutorials.com/
http://vimeo.com/channels/ncsuunity
http://vimeo.com/ryanzec
http://diamondtearz.org/lists/unity3d-scripting/

http://www.unity3d-france.com/
http://www.tornadotwins.com/

http://forestjohnson.blogspot.com/
http://anomalousunderdog.webs.com/UnityProjectUploads/

Good luck xD

Thanks for the feedback! I plan on writing a detailed tutorial on my findings to give back the community as well (this is a firm belief I have about anything arts related).

If I learn how to do something, I should pass it on. Thanks for the response and the info, it is super helpful and those inventory systems should do the trick, at least in terms of getting me started.

I’m certainly not affiliated with this site, but i’ve found quite a few interesting things for sale on it. There’s a few really good scripts there including point and click naviation. Something someone askes for nearly every day on the forum. $4 for all those scripts is a time saver.

All good.

To get the point and click navigation in a 3D environment working as expected you’ll need to look into path finding =X

This looks promising: http://forum.unity3d.com/viewtopic.php?t=43822&highlight=pathfinding

And the stat system is pretty straight forward. Just displaying your health, strength variables etc with a themed unity GUI (or 3D objects attached to the camera to appear as a gui etc)
http://unity3d.com/support/documentation/Manual/Game%20Interface%20Elements.html

Thank you. This is a great primer and should be enough to get me started. If I have more questions I’ll relay them back to here.

Good luck.

Post your progress =)

Progress so far:

I have been able to create a GUI with a specific set on the background that toggles on and off by clicking a certain button. So that is good!

My next question is how to determine health and damage. I’ve noticed a lot of tutorials out there on having lives and respawing; I simply want a standard HP system. Does anyone know a good tutorial for this? I understand how the code would work, but not actually how to code it. Here is my understanding of how it would function.

Basically, the player has some base stats that influence his health and damage. These stats are broken into things such as Strength, Dexterity, Vitality, and Wisdom. Each of these will modify the player’s in-game abilities.

I just need help with setting up HP, and then I can figure the rest out myself. So, if the player has a Vitality score of 16, his health will be double that. At the start of the game Vitality is an arbitrary number of my choosing. For now we don’t need to worry about the player modifying it, so we can just say it stays at 16.

I understand the math of it, but how do I actually code this?

Player HP = (Vitality)2

Now that the player’s HP is determined, I want it to be linked to a GUI texture with a mask on it (I assume this is how it would work). Whenever the player is hit, the game will determine what percentage of the player’s health was taken away and will subtract it from the HP bar by covering it with an alpha channel mask. So, if the player is at 16 HP, or 50% of his max health, the alpha channel will cover 50% of the Health bar GUI.

Thanks for the help on this! Once I figure it out I’ll be uploading some screens :wink:

Var playerHpPerc : int;
Var playerHealrate = 0.1;
Var playerStatus : String = “idle”;
Var playerVit : int = 50;
Var playerHp_max : int;
Var playerHp_current : int;

function Start {
playerHp_max = playerVit * 2;
playerHp_current = playerHp_max;
}

function Update {
playerHpPerc = (playerHp_current / playerHp_max) * 100;
// Slowly heal player if they are not in combat
if (playerStatus != “combat”){
playerHp_current += playerHealrate;
}
}

Code probably doesn’t work, but you get the idea I hope :smile:.

I don’t actually know how to use masks in Unity, but it is something I need to work out.
Here’s a place to start if you want to head down that path: http://www.unifycommunity.com/wiki/index.php?title=Layers

However, an easy way to do it (considering the Diablo intentions :smile:) would be by having health graphic images/animations (to simplify for proof of concept) for 10%, 20%, 30%, 40% etc… 100%. Then just change the frame of the animation, or update the material/gui texture/etc based on the current health.

Wait… better yet combine the ideas (if you wanted to work out the masking)… have a static “health bar vial” mask and an animated health “liquid” (Diablo-ness) graphic/animation
This this graphic/animation have its y position move up/down based on the % of player health.
If that makes any sense?

…If you work out masking let me know :stuck_out_tongue:

I don’t expect to have solved anything for you, just trying to help a fellow Diablo fan :stuck_out_tongue:

EDIT: http://answers.unity3d.com/questions/1093/how-do-i-mask-off-specific-parts-from-a-plane-or-cube

Thank you oh so much, that is really really helpful to me and definitely gives me an idea as to how the code would work. It’s a good starting point!

Currently the game has taken a sort of Greek mythological approach. I didn’t want to fully rip off Diablo, so now it is sort of a cross between Diablo gameplay and God of War aesthetics.

Here is something I did the other day, that you might find helpful.

function DrawBar(BarLeft:int, BarTop:int, BarTexture:Texture, MaxValue:float, Value:float)
{
    var LocationRect:Rect = Rect(BarLeft,BarTop,EmptybarTexture.width,EmptybarTexture.height);
    var DrawRect:Rect = Rect(0,0,EmptybarTexture.width,EmptybarTexture.height);
    var DrawWidth:int;

    DrawWidth = EmptybarTexture.width*(Value/MaxValue);
    GUI.BeginGroup (LocationRect);
        GUI.DrawTexture (DrawRect, EmptybarTexture);
        GUI.BeginGroup (new Rect (0, 0, DrawWidth, EmptybarTexture.height));
            GUI.DrawTexture(DrawRect, BarTexture);
        GUI.EndGroup ();
        GUI.Label(Rect((DrawRect.width/2)-10,-5,40,50),Value.ToString());
    GUI.EndGroup ();
}

You need to add the following to the top of your script, then drag the textures you want to use into these objects in the inspector.

var EmptybarTexture:Texture2D; 
var HealthbarTexture:Texture2D;

After you have these at the top, and the textures you want to use assigned, it should work just fine. Use the following to draw the bar…

DrawBar(0,0,HealthbarTexture,MaxHP,CurrentHP);

Substitute whatever variables contain your Max HP and Current HP in the line above.

Hope this helps,
-Larry

Just signing to keep track of the updates. I’m in planning stages of a similar type of play… locked cam and instead of point and click, you’re able to control the character directly with a gamepad.

Good luck! :slight_smile:
~t

@larry

this seems more efficient, the begingroup you used didnt seem to clip my textures and always would draw the current health full length.

function DrawBar(BarLeft : int, BarTop : int, BarHeight : int, BarTexture : Texture, MaxValue : float, Value : float)
{
var DrawWidth : int;

DrawWidth = MaxValue * (Value/MaxValue);

GUI.DrawTexture(Rect(BarLeft, BarTop, MaxValue, BarHeight), StatusBarEmptyTexture);
GUI.DrawTexture(Rect(BarLeft, BarTop, Value, BarHeight), BarTexture);
}

Wowsers, I only just got back into Unity to find this thread.

That screen shot is pure sex. :smile:

I just finished my system where the user can walk around, kill enemies and pick up items. The next stage is getting the inventory gui, wield/wear and drop systems working.

It’s mostly written in C# and what’s in javascript is being converted. If you would like to see another way of doing it I can send you the project.

Hey!! That game is really looking great, and im trying to approach the same style game also. i was wondering, maybe you can share you camera script with us because i really really really want that type of camera :smile:

are you still working on this?

Are you? This looks very interesting and many people; including myself, would like to see your progress.