- Home /
No appropriate version of 'iTween.PutOnPath' for argument list ... was found
I'm trying to instantiate and then place an object on a path and allow the user to move the object along the path. I'm using iTween without success and have been trying various things for a week (I'm new to this). I confirmed that I've iTween, iTweenPath, and iTweenPathEditor in my Plugins folder (I notice that Mono editor still doesn't recognize the iTween functions as I type). Unity is giving me this error:
Assets/Mellon/Scripts/Object Path Script.js(2,25): BCE0023: No appropriate version of 'iTween.PutOnPath' for the argument list '(System.Type, System.Collections.Hashtable, int)' was found.
This is my GUI Script.js
//This script instantiates objects using the GUI
var prefab1 : GameObject;
var prefab2 : GameObject;
var prefab3 : GameObject;
var prefab4 : GameObject;
var prefab5 : GameObject;
function OnGUI () {
// Make a background box
GUI.Box (Rect (10,10,100,240), "Create Bead");
// Make the first button. If it is pressed, Round Sm bead will be created
if (GUI.Button (Rect (20,40,80,30), "Round Sm")) {
//Instantiate the object at the position and rotation of this transform
var instance1 : GameObject = Instantiate(prefab1, Vector3(10,50,-20), transform.rotation);
}
// Make the second button. If it is pressed, Round Lg bead will be created
if (GUI.Button (Rect (20,80,80,30), "Round Lg")) {
var instance2 : GameObject = Instantiate(prefab2, Vector3(10,50,-20), transform.rotation);
}
// Make the third button. If it is pressed, Rondel bead will be created
if (GUI.Button (Rect (20,120,80,30), "Rondel")) {
var instance3 : GameObject = Instantiate(prefab3, Vector3(10,50,-20), transform.rotation);
}
// Make the fourth button. If it is pressed, Oval Sm bead will be created
if (GUI.Button (Rect (20,160,80,30), "Oval Sm")) {
var instance4 : GameObject = Instantiate(prefab4, Vector3(10,50,-20), transform.rotation);
}
// Make the fifth button. If it is pressed, Oval Lg bead will be created
if (GUI.Button (Rect (20,200,80,30), "Oval Lg")) {
var instance5 : GameObject = Instantiate(prefab5, Vector3(10,50,-20), transform.rotation);
}
}
This is Object Path Script.js
function Update () {
iTween.PutOnPath(GameObject, iTween.Hash("path", iTweenPath.GetPath("beadstring")), 0);
}
Any suggestions what for needs to be changed? Thanks!
I've never used iTween, but...Script.js is attached to the object that you want to move, right? So, try with gameObject as parameter, and not GameObject...Hoping to have understood the logic.
I'm thinking it may have to do with iTween not being set up properly too. When I watch the video (http://pixelplacement.com/2010/12/03/visual-editor-for-itween-motion-paths/), $$anonymous$$ono recognizes and finds the functions as Bob types (e.g., $$anonymous$$oveTo, etc.) but $$anonymous$$e doesn't.
Answer by Russ Morris · Jan 17, 2012 at 06:52 PM
function Update () {
iTween.PutOnPath(GameObject, iTween.Hash("path", iTweenPath.GetPath("beadstring")), 0);
}
So, see the bit where you have GameObject... well you're declaring a Type there, not an actual gameObject.
Change GameObject to gameObject so that it refers to the gameObject instead...,, function Update () { iTween.PutOnPath(GameObject, iTween.Hash("path", iTweenPath.GetPath("beadstring")), 0);
}
Check where it says GameObject, it should say gameObject for a start, no?
Answer by dannyskim · Jan 17, 2012 at 06:23 PM
You're using the
iTween.Hash();
method of creating your hash table which is only supported in the c# version of iTween I believe. You need to call it using the inline Hash table creation method for javascript:
http://itween.pixelplacement.com/gettingstarted.php
I'm not quite sure how using GetPath would work with it all, so you may have to experiment with that.
Answer by abelegu2 · Apr 15, 2015 at 01:07 PM
It appears you're just using the function the wrong way. According to iTween's Documentation, PutOnPath only accepts the following parameters in the order shown:
PutOnPath(GameObject target, Vector3[] path, float percent)
PutOnPath(GameObject target,Transform[] path, float percent)
PutOnPath(Transform target, Vector3[] path, float percent)
PutOnPath(Transform target, Transform[] path, float percent)
You used:
iTween.PutOnPath(GameObject, iTween.Hash("path", iTweenPath.GetPath("beadstring")), 0);
...and PutOnPath does not take the HashTable parameter you used (i.e. iTween.Hash). I would suggest using something else (such as iTween.MoveTo function, which does use HashTables), but you know best what you need your code to do. Refer to the documentation for more information on iTween functions.