- Home /
[iTween] ShakePosition and local coordinates
Hi all, I've some issues trying to shake an object in local coordinates with iTween. Indeed, I've an object attached to my camera, and this camera is rotating around my scene. I wanted to use ShakePosition to shake this object, but it seems that "islocal" just doesn't work, because my object move from Screen to a strange position (World coordinates?). If I stop rotating the camera around, everything is fine.
My code:
Hashtable wrd1 = new Hashtable();
wrd1.Add("amout", new Vector3(2,0,0));
wrd1.Add("islocal", true);
wrd1.Add("time", 1f);
iTween.ShakePosition(aText.gameObject,wrd1);
aText is my 3D object attached to my camera, and this script is on the camera.
Any solution? Thanks a lot !
Answer by Lttldude · Apr 30, 2012 at 11:37 PM
I know this is an old question, but I had the same problem and found a fix if anyone out there has similar issues. You just need to make a minor change in the iTween.cs file.
Go to this function:
void GenerateShakePositionTargets()
and change
vector3s[0]=transform.position;
to
if(isLocal)
{
vector3s[0]=transform.localPosition;
}
else
{
vector3s[0]=transform.position;
}
Hope this helps everyone.
This is awesome! I wish I could upvote this answer :D Thanks a lot, Lttldude
O$$anonymous$$G, thanks so much for that. surprised its still not fixed on iTween's end.
Answer by sriram90 · Dec 08, 2011 at 12:53 PM
Hi cayou66 ,
try with this... i have used this already and worked well..
iTween.ShakePosition(target,iTween.Hash("x",0.3f,"time",1.0f)); // target game object ... that is object you need to make shake.
// x is axis here.
Answer by cAyouMontreal · Dec 08, 2011 at 04:41 PM
Hi sriram90, I'll try but I'm pretty sure that it won't work.
It seems that it's just impossible to Shake and Move an object at the same time... I tried to modify the iTween function, without success...
I'll try also a custom function, without iTween.
Thanks !
Answer by cAyouMontreal · May 01, 2012 at 01:13 PM
Wow that's really cool if it works ! You should contact the developer of iTween to tell him to fix this bug. Thanks !
Answer by Mezzerzmith · Nov 28, 2012 at 02:54 PM
Hi I just had the same problem and solved it through putting the shaking on an empty gameObject, and when it shakes, add (make sure not to set) its X and Y shaking to the camera, then you can move at the same time.
Hope you get it to work!
Your answer
Follow this Question
Related Questions
Touch point to world coordinate and local coordinate 1 Answer
iTween - Increase shake over time? 1 Answer
iTween Shake intensity issues 1 Answer
Camera shake 11 Answers
How to allow movement during camera shake? (iTween) 0 Answers