HexDev Alpha Build 14
- Ice
- Penguins
- Alligators
- Bow & Arrow
- Pickaxe
- Mineable Copper Ore
- Ash
- Caves
- Skeletons
- Edit: Treasure Chests (with nothing in them and very cool audio)
Coming soon: Banjos and Penguin mounts?
Coming soon: Banjos and Penguin mounts?
I found an interesting discussion on Eric Heimburg’s G+ page about “floaty numbers” in Unity, and offered to share my solution to this problem as seen in HexDev, so here it is! Maybe someone will come looking for Scrolling Combat Text in Unity and this code will help!
So to get things started, here’s a quick screenshot of the implementation in HexDev:
The basic concept is to display numbers above a unit whenever they take damage. The number should rise for a certain height at a given speed and then poof away! Nice and simple right?
So, to do this using my approach, we need a couple things:
So, Step 1) In my projects, I have created a prefab called SCTText which looks like this:
Nothing fancy, again just a GameObject that has a TextMesh object on it. The beauty of it is that you can change this prefab to have a mesh or particles or whatever you want on it. The number will be updated by the ScrollingCombatText script below.
For step 2, all of my units have a special behaviour attached to them that manages their health. Whenever they take damage, they simply use the Unity SendMessage API to notify other MonoBehaviour’s attached to the game object that the unit has taken damage. This will probably need to be tailored to your project.
And for step 3, I just attach the script below to my GameObject, give it the Prefab we defined in step 1, configure some parameters and whenever the unit takes damge, voila! Scrolling combat text! Here’s what the configuration of the script looks like on my units (each unit can have their own values or we can use the default values):
using UnityEngine; using System.Collections; using System.Collections.Generic; public class ScrollingCombatText : MonoBehaviour { // How fast will the spawned text object rise public float RiseRate = 4.0f; // How high should the spawned text object rise public float RiseHeight = 10.0f; // Prefab with an attached TextMesh component that will be spawned when damage is taken public GameObject TextPrefab = null; private List floatingTextObjects = new List(); // This will be the starting height of the floating numbers private float initialHeight = 0.0f; // Use this for initialization void Start () { // If this component is attached to a CharacterController, use the CharacterController's height attribute to set the initial height CharacterController charController = gameObject.GetComponent(); if (charController != null) initialHeight = charController.height; } // Requires the GameObject to have a method call to: SendMessage("DamageTaken", int) void DamageTaken(int damageAmount) { // Create a new text object and set the starting height and text GameObject textInstance = (GameObject)Instantiate(TextPrefab); textInstance.transform.parent = gameObject.transform; textInstance.transform.localPosition = new Vector3(0, initialHeight, 0); TextMesh mesh = textInstance.GetComponent<TextMesh>(); mesh.text = damageAmount.ToString(); // Add to the list of floating text objects to update every frame floatingTextObjects.Add(textInstance); } // Update is called once per frame void Update() { // Cache all text meshes to be deleted and later delete them List objectsToDelete = new List(); foreach (GameObject floatingTextObject in floatingTextObjects) { float riseDelta = Time.deltaTime * RiseRate; Vector3 newPosition = new Vector3(floatingTextObject.transform.localPosition.x, floatingTextObject.transform.localPosition.y + riseDelta, floatingTextObject.transform.localPosition.z); floatingTextObject.transform.localPosition = newPosition; floatingTextObject.transform.LookAt(floatingTextObject.transform.position + Camera.mainCamera.transform.forward); // Delete this floating text object if it exceeds our RiseHeight property if (floatingTextObject.transform.localPosition.y >= initialHeight + RiseHeight) { objectsToDelete.Add(floatingTextObject); } } foreach (GameObject objectToDelete in objectsToDelete) { floatingTextObjects.Remove(objectToDelete); Destroy(objectToDelete); } } }
I’m having too much fun playing with Cube Slimes and Burning Trees!
Desining emergent gameplay is awesome!
Attention loyal supporters of HexDev!
<crickets>
Ahem, ok, so I made the link to HexDev at the top point directly to the game on Kongregate. This will help me save some web space and generate a bit of revenue (hahahaha), ahem… as I keep developing. At some point, if Kongregate supports the Shared Content API for Unity, I’m ready to integrate it into the game so people can share custom maps. Someday I may have to write my own content sharing API if they don’t deliver.
Here’s where you come in! If you have a Kongregate account, I need a few more votes on the game to see how people like it so far. The problem with Kongregate is that once games fall off the “new” list, they never get seen again, unless they are 5/5 star games which make the front page. But at the same time, that makes sense for their business because a lot of garbage and prototype stuff gets put there, so they have to.
So, long story short:
Thanks!
Posted a new HexDev build with sound! Filesize went up quite a bit. Also debugging ore collection, so if you place any mountain tiles, you might see some ore spawn. Right click to gather, but that’s all you can do for now.
Oh, and I reverted some of the graphics back to smooth shading instead of flat shading to get the nice outlines. I think I like it.
I’m starting to work on implementing a resource gathering system for the game, because I think it’s fun to collect things in an RPG. At the moment, my current design plan is to have Mountain Tiles spawn Ore Nodes which can be harvested and returned to the Blacksmith so he can produce metal for things like Swords! All of this got me thinking more about dependency chains with my current set of tiles. So here’s a quick graph that shows some of HexDev’s tiles and their interactions:
I guess there’s a couple things to point out about this sytem:
I’m not exactly sure where I’m going with this, but my thought is to provide more tile:tile interaction possibilities, so that different tiles can interact. Some off the top of my head ideas:
I guess I want to avoid just going to town creating new enemy units and clever ways to defeat them. I want the game to be more than just smash the enemies, and designing a system to create emergent gameplay is tricky. I’m super un-experienced at this and I don’t have as much time as I would like to work on it, but that’s what’s on my mind!
In the last week or so, I’ve been extremely busy with other things, but managed to implement 2 new Tiles with 2 new game mechanics!
Swamp

Game Mechanic: Poison AoE
Description: Swamps are poisonous tiles that deal damage over time while the user is within the noxious gas that the tile emits. Don’t linger too long!
Future Mechanic: Possibly adding a mob spawner or an item spawner to give players a reason to enter swamps.
Mountain

Game Mechanic: Obstruction
Description: Mountains are simply “pretty” obstructions” that prevent players from passing through the tile. This allows TileSet designers to create divides or paths that the player must walk around or through.
Until next time! Happy Hexing!
Posted a new build with the updates that I mentioned in my last post. With this build, you get not only 1 new Debug Quest, you get 2! Try em out, comments below if you have feedback.
Thanks!
No new builds lately because I’ve been working on quite a few small features. Here’s a brief list of things I’ve been working on and you can expect to see in the next patch. Thanks to everyone who supplied feedback so far, it’s been really helpful!
Quests
Combat
Game Mechanics
So, I leave you with a screenshot of the avatar carrying the crystal.
This weekend, I let my 4 1/2 year old son play HexDev while I was working on some new gameplay mechanics (none of those are really shown here). While he was playing, I documented his thoughts and captured his experience on video to share.
Some of his thoughts (not shown on the video):
Here’s his experience. I personally like the last 15 seconds. ![]()