iTween Script - Making a variable editable in the inspector

I have a iTween Script and I want to add in a Speed Variable to be able to control the Speed in the Inspector. Im new to scripting and need help figuring it out? Or changing the Time variable to be able to modify it in the inspector.

var path : Transform[ ];

function Start ()
{
iTween.MoveTo(gameObject,{“path”:path,“time”:10,“orienttopath”:true,“looktime”:.6,“easetype”:“easeInOutSine”,“oncomplete”:“complete”});
}

function OnDrawGizmos()
{
iTween.DrawPath(path);
}

There is a time variable “time:10” which takes 10 seconds, how would I modify this script to be able to change the variable of 10 in the inspector?

Very simple for most but Im trying to learn.

Cheers!

I use C# so it’s a little different, but i think all you need to do is add a “var time : float;” at the top of the script.

var path : Transform[];
var time : int;

function Start () 
{
iTween.MoveTo(gameObject,{"path"ath,"time":time,"orienttopath":true,"looktime":.6,"e asetype":"easeInOutSine","oncomplete":"complete"}) ;
}

function OnDrawGizmos()
{
iTween.DrawPath(path);
}

untested but should work

I think you’ll want time to be a float though, for iTween.

Also, iTween now has a “speed” variable which will allow you to set a consistent speed for different situations. Judging by your attempted setup it looks like you are interested in adjusting the iTween’s speed as it plays? If so this isn’t possible. iTween is meant to setup an animation and let it run its course.

Good luck.

Actually you can send either to iTween and it will sort out what it needs :wink:

Awesome! and such a fast response you guys are great!!!

If I cant change the speed in the inspector for this one its fine at least I know know how to modify the scripts for use in the inspector. Thank you Beezir, apples and pixelplacement1.

var path : Transform[ ];
var time : float;

function Start ()
{
iTween.MoveTo(gameObject,{“path”:path,“time”:time,“orienttopath”:true,“looktime”:.6,“easetype”:“easeInOutSine”,“oncomplete”:“complete”});
}

function OnDrawGizmos()
{
iTween.DrawPath(path);
}