- Home /
Newbie trying iTween
Got iTween dragged into my project and I can see the code is executing when I hit play because the inspector shows the tweens going on...
What I'm trying to do:
I've got a scene created in Cinema 4D, with a few null objects placed for target landing spots for my camera. I eventually will have a clickable GUI element that will step through each of the landing places, and the camera should just tween over to each null's transform.
However, just to start scripting, I've made a simple script and attached to my camera as follows:
var thingToMove : GameObject; var stop1 : GameObject;
function Start () { iTween.rotateTo(thingToMove, {"transform.rotation":(stop1.transform.rotation), "time":3, "transition":"linear"}); iTween.moveTo(thingToMove, {"transform.position":(stop1.transform.position), "time":3, "transition":"linear"}); }
When I hit play, I can see that the script is executing, because the inspector view shows two tweens in process then they disappear. There are no errors, but the camera doesn't move (neither in game view or scene view)
I also tried by applying this to a game model instead of the camera, but still nothing.
I know this is super remedial, but I just need a kick in the right direction.
Thanks!
UPDATE
OK, so I got it working on position OR rotation, but not BOTH. Here's my updated code...why does it only do one tween? How can I do both?
var thingToMove : GameObject; var stop1 : Transform; private var transSpeed = 10;
function Start () { iTween.moveTo(thingToMove,{"position":Vector3(stop1.position.x, stop1.position.y, stop1.position.z), "time":transSpeed, "transition":"easeInOutExpo"}); iTween.rotateTo(thingToMove,{"rotation":Vector3(stop1.rotation.x, stop1.rotation.y, stop1.rotation.z), "time":transSpeed, "transition":"easeInOutExpo"}); }
Answer by interactiveBoy · May 21, 2010 at 07:28 PM
Solved!
Needed to read eulerAngles from the source object and apply that to the object I'm moving.
var thingToMove : GameObject; var stop1 : Transform; private var transSpeed = 3;
function Start () {
iTween.rotateTo(thingToMove,{"rotation":Vector3(stop1.eulerAngles.x, stop1.eulerAngles.y, stop1.eulerAngles.z), "time":transSpeed, "transition":"easeInOutExpo"});
iTween.moveTo(thingToMove,{"position":Vector3(stop1.position.x, stop1.position.y, stop1.position.z), "time":transSpeed, "transition":"easeInOutExpo"});
}
Answer by typane · Nov 30, 2012 at 08:57 AM
For those who want the C# solution:
iTween.RotateTo(clickedObject, new Vector3(defaultRot.eulerAngles.x, defaultRot.eulerAngles.y, defaultRot.eulerAngles.z), moveTime);
Your answer
![](https://koobas.hobune.stream/wayback/20220613014158im_/https://answers.unity.com/themes/thub/images/avi.jpg)