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?