Advanced Combat or Damage System

Hello,

I have come here to ask how to make a good looking combat system, like the one you see in world of warcraft where you attack the enemy and text comes out of the enemy at random places.

I have the damage all figured out. All I need is to do the display.

So you’re looking for something of a programmable UI toolkit? Am I mistaken on this? Have you tried searching the Asset Store inside the unity editor? To access it click on windows and then the Asset Store. When that loads, go under Scripting then GUI.

Btw, sorry if I over simplified. I’m used to talking with special needs people.

HaHa, no problem.

Thank you for the reply, and yes I have(the asset store). But I couldn’t find anything less than 65euros, unity was enough by itself!

What I think I need is some tips on how to go about setting the system up.

Its not something of a programmable UI toolkit.

Its like in wow, when you attack an enemy a number appears in a random area next to the enemy.

P.S: I can do the animation and text effects myself, all I need is to have the number appearing next to the enemy.

Can anyone tell me how to efficiently achieve this?

What are you stuck on? How to put text on screen? I’d recommend a text mesh, so you can just position it’s transform over the target’s head.

Ok,

Here is what I’ve managed to come up with.

Make a new GameObject call it Transform, make it a child of the enemy. Make a 3DText call it what you want, and make it a child of the GameObject called Transform which is a child of the enemy. Make a new GameObject call it TransformMatrix make Transform a child of it.
Make as many GameObjects called Transform as you want (I have 9), you can label them Transform1, Transform2, Transform3, ect…

Attach this script to the 3DText which you called whatever you wanted to call it(I labeled mine text1, text2, text3).

3DText.js:

#pragma strict

var numberText : String;
var cameraToLookAt : Camera;

var canUpdate : boolean = false;

function Start () {

cameraToLookAt = Camera.main;

}

function Update () {

if (canUpdate == true) {

var v : Vector3 = cameraToLookAt.transform.position - transform.position;

v.z = v.x = 0.5f;

transform.LookAt( cameraToLookAt.transform.position - v );

transform.Rotate(0, 180, 0);

transform.Translate(0, 1.3 * Time.deltaTime, 0);

if (transform.position.y >= 5) {

canUpdate = false;

renderer.enabled = false;

}

}

}

function Activate (no : int) {

renderer.enabled = true;

numberText = no.ToString();

canUpdate = true;

}

Attach this script to the TransformMatrix you made.

TransformMatrix.js:

#pragma strict

var text1 : GameObject;
var text2 : GameObject;
var text3 : GameObject;
var text4 : GameObject;
var text5 : GameObject;
var text6 : GameObject;
var text7 : GameObject;
var text8 : GameObject;
var text9 : GameObject;

var random : int;

var no : int;

function TextActivate (num : int) {

random = Random.Range(1, 9);

no = num;

if (random == 1) {

text1.SendMessage(“Activate”, no);

}

if (random == 2) {

text2.SendMessage(“Activate”, no);

}

if (random == 3) {

text3.SendMessage(“Activate”, no);

}

if (random == 4) {

text4.SendMessage(“Activate”, no);

}

if (random == 5) {

text5.SendMessage(“Activate”, no);

}

if (random == 6) {

text6.SendMessage(“Activate”, no);

}

if (random == 7) {

text7.SendMessage(“Activate”, no);

}

if (random == 8) {

text8.SendMessage(“Activate”, no);

}

if (random == 9) {

text9.SendMessage(“Activate”, no);

}

}

Like I said I had 9. you can have as many as you like.

now attach this to a first or third person controller.

FirstOrThirdPersonController.js:

var damage : int = 20;

function Update () {

if (Input.GetKeyDown(“a”) {

var transformMatrix : GameObject = GameObject.Find(“TransformMatrix”);

transformMatrix.SendMessage (“TextActivate”, damage);

}

}

The problem is its not doing it at the right time and it doesn't print the right damage when you have more than one damage doing script. Can I have some help with this please?

OMG, OMG, OMG.

You know what I am ?

Thats right… I am a complete I-D-I-O-T!!!

3DText.js:

#pragma strict

var numberText : String;
var cameraToLookAt : Camera;

var canUpdate : boolean = false;

function Start () {

cameraToLookAt = Camera.main;

InvokeRepeating(“TransformTextUpdate”, 0.1, 0.01);

}

function TransformTextUpdate () {

if (canUpdate == true) {

var v : Vector3 = cameraToLookAt.transform.position - transform.position;

v.z = v.x = 0.5f;

transform.LookAt( cameraToLookAt.transform.position - v );

transform.Rotate(0, 180, 0);

transform.Translate(0, 1 * Time.deltaTime, 0);

if (transform.position.y >= 5) {

canUpdate = false;

renderer.enabled = false;

}

}

if (canUpdate == false) {

transform.position.y = 3;

}

}

function Activate (no : int) {

var myText : TextMesh = GetComponent(TextMesh) as TextMesh;

numberText = no.ToString();

myText.text = numberText;

renderer.enabled = true;

canUpdate = true;

}

There. Just replace that other 3DText.js in the previous reply.

Have you been able to work this out? if you have not, let us know.

I’ll admit I am confused by your code, as it is not in code tags.

You can “tag” your code by going to advanced by clicking the “Go Advanced” button:

… and then highlight the code you want in tags:

… and then clicking on the code tag button:

… this will make code with TAGS that looks like this:

… and it will display like this:
** **function SomeFunction (var1, var2) { if (var1 > var2) { DoSomething(); } else { DoSomethingElse(); Debug.Log ("Did something else!"); if (var1 = var2) { GoCrazy(var1); } } }** **
-
If you don’t use code tags, the code looks confused:

function SomeFunction (var1, var2) {
if (var1 > var2) {
DoSomething();
} else {
DoSomethingElse();
Debug.Log (“Did something else!”);
if (var1 = var2) {
GoCrazy(var1);
}
}
}