- Home /
iTween's inaccuracy of final position
So I've been using iTween for a while and it's been quite awesome, however I just noticed a very concerning issue. I have an object, my camera in this instance, that was designated to move from (0,0,0) to (38, 48, 0). This is the call:
iTween.MoveAdd(cam.gameObject, iTween.Hash(
"amount", FinalCamOffset,
"time", 1.0f,
"easeType", iTween.EaseType.easeOutExpo
));
Where FinalCamOffset was defined as (38, 48, 0) and shown in the output window for confirmation. Looking at where it ended up these were the camera's coords after the tween was done: (37.96289, 47.95313, 0)
You could say that the error is very slight and practically invisible in this case, but these slight errors can accumulate and throw it off its proper alignment.
Is this a real bug or am I missing something on my end?
Thanks.
Answer by Jason B · Feb 18, 2011 at 09:06 PM
I've never used iTween before and don't really know what it does that a simple Lerp won't, but there's something there called EaseType? It looks like it's smoothing the motion as it comes to a stop. The smoothing is so aggressive that it will eventually come to a complete halt as it gets closer and closer to its target. I suspect this would be fixed if you changed the EaseType to something else, but again, I've never used iTween.
If this doesn't solve the issue, you could always check to see if the object is within a certain distance of its destination; for instance, if the object you're moving is 0.1 unit or less away from its destination, you could command it to snap to the destination position.
You are correct, iTween does allow the use of different "ease types", and as my code sample above shows I was using "easeOutExpo". That being said, I could try out different ease types, but I'm using this one for aesthetic reasons. I hoped that at the very least iTween would've had a final line executing in the end of each tween that makes sure that the GameObject ends exactly in the designated spot.
Answer by equalsequals · Mar 09, 2011 at 09:25 PM
A bit of a hack, but you could always force that to happen by adding an "oncomplete" argument to the hash args, which then manually sets the position to those coordinates if you're looking for pixel-perfect precision.
Hope that helps
==
Your answer
![](https://koobas.hobune.stream/wayback/20220613105100im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
EdyVehiclePhysics 0 Answers
2D 360 degress platformer example needed 0 Answers
How to punch a ball without loosing its momentum? 3 Answers
itween cameraFadeTo not working 1 Answer