Hello
I have a functional script based on ITWEEN.
I would want to make 3 guibutton to change dynamically the speed by step of 10.
One to increase the speed of + 10 by click
one to decrease the speed of - 10 by click
one to put back the speed to the initial velocity of the script
Thank you for your help
#pragma strict
public var target_Path1 : GameObject;
public var time = 10.0;
public var target : Transform ;
private var tabt : Transform[];
private var running = false;
private var paused = false;
private var fraction = 0.0;
function SetPath (pathObject : GameObject){
var id : int = 0;
tabt =null;
tabt = new Transform[pathObject.transform.childCount];
for(var child: Transform in pathObject.transform) {
tabt[id++] = child.transform;
}
WalkThePath();
}
function WalkThePath() {
paused = false;
running = true;
fraction = 0.08;
while (running) {
transform.position = iTween.PointOnPath(tabt, fraction);
if (!paused)
fraction += Time.deltaTime / time;
if (fraction > 1.0) fraction = 0.0;
var futurePos = iTween.PointOnPath(tabt, fraction + 0.02);
transform.LookAt(target);
yield;
}
}
function Start()
{
SetPath(target_Path1);
}
function OnGUI(){
if(GUI.Button(Rect(290,80,100,20), "commencer"))
{
SetPath(target_Path1);
}
if(GUI.Button(Rect(390,80,100,20), "Pause"))
{
paused = true;
}
if(GUI.Button(Rect(490,80,100,20), "Reprise"))
{
paused = false;
}
if(GUI.Button(Rect(390,100,120,20), "Reculer par étape"))
{
fraction -= 0.2 / time;
if (fraction < 0.0) fraction = 0.0;
}
if(GUI.Button(Rect(510,100,120,20), "Avancer par étape"))
{
fraction += 0.2 / time;
if (fraction < 0.0) fraction = 0.0;
}
if(GUI.Button(Rect(590,80,100,20), "Stop"))
{
running = false;
}
// Here the 3 buttons for Increase or decrease by step 10, or put back to the initial speed
if(GUI.Button(Rect(590,120,100,20), "Speed + 10 "))
{
// ??????????????
}
if(GUI.Button(Rect(590,140,100,20), "Speed - 10"))
{
// ??????????????
}
if(GUI.Button(Rect(590,160,100,20), "Initial speed"))
{
// ??????????????
}
}