- Home /
Scroll text works, but load level is to fast!
I am using a script to load text on the screen and it scrolls down, wish it was up but my issue is that i added a load function at the bottom and it loads the level before it even scrolls the text.
<code>
public var intro : String[];
public var off : float;
public var speed = 50;
function OnGUI()
{
off += Time.deltaTime * speed;
for (var i = 0; i < intro.Length; i++)
{
var roff = (intro.Length*-20) + (i*20 + off);
var alph = Mathf.Sin((roff/Screen.height)*180*Mathf.Deg2Rad);
GUI.color = new Color(1,1,1, alph);
GUI.Label(new Rect(650,roff,Screen.width, 30),intro[i]);
GUI.color = new Color(1,1,1,1);
Application.LoadLevel ("Level1");
}
}
</code>
How can i get it to wait for the text to finish?
If you know how long it's going to take then you could use WaitForSeconds
.
The audio clip is 12 seconds long, how do i add the waitforseconds?
Answer by andrewjm10 · Jul 13, 2013 at 01:21 AM
Never mind i fixed it, thanks for the reply's it did help. Looking at links and unity wiki, i add:
function Start (){
audio.Play();
yield WaitForSeconds (15);
Application.LoadLevel ("CreateCharacter");
}
Now it works great!
Answer by Slobdell · Jul 13, 2013 at 12:08 AM
Why not make them push a button to proceed to the next level
Because it's an into not a menu, the text scrolls down and has music playing in the background.
Or do you mean like a skip button?
What about checking the position of the scroll text and loading the level when it gets to a certain point? Also, the OnGui function is. called every frame so that whole for loop is completed within one frame, don't think that's what you want
Ok, thanks for the info how do i fix it? so it is not all inside the OnGui? last time i tried it was full of errors.
You don't want to use a loop to move something on the screen. You have to lerp it. You can check out mathf.lerp for this situation but basically you just want to have a float for its position and then change the float every frame by a little bit. Like in OnGui you could just do textPosition += Time.deltaTime * aSpeedYouLike
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Unity error "scripts exist in multiple locations" 1 Answer
Networking Problem Please Help!!! [IMPORTANT] 0 Answers
Spawn Script Issue 0 Answers
Help Solve This 2 Answers