RPG GUI Comments help..

Hi…

I´m doing a comment system for rpg games, but comments have a special task, is to write by each letter one per one, on the screen and not to show all the phrase all in one time…

some tips or ideas how to do that?

this is what i have :

( comments.js )

private var theComment : GUIText;

function Awake () {
theComment = GetComponent(GUIText);
}

function WriteComment (comment :String, theTime : float){
theComment.text = comment;
yield WaitForSeconds(theTime);
theComment.text = "";
}

then from other script :

private var commentManager : comments

function Awake (){
commentManager = GameObject.Find("comments").GetComponent("comments");
}

function OnTriggerEnter(other: Collider){
if (other.gameObject.tag == "Player"){
   commentManager.WriteComment("Hello!, how are you?", 3.5f);
   }
}

That will show a comment on the screen for a certain specified time… that is ok, but what í want is to write each letter at one time like if you are writing in an old typewriter…

thanks

http://www.unifycommunity.com/wiki/index.php?title=AutoType

try something like this (untested)

function WriteComment (comment :String, theTime : float, letterDelay : float)
{
   var i : int = 1;
   for( i = 1; i <= comment.length; i++)
   {
      theComment.text = comment.Substring(0,i);
      yield WaitForSeconds(letterDelay)
   }
   yield WaitForSeconds(theTime);
   theComment.text = "";
}

Thanks friends, i will try both… Greetings!