- Home /
iTween ShakePosition stalls forward movement?
I'm trying to use iTween's ShakePosition to add a camera shake effect. I have the camera parented to an object that is aligned to and moving along an iTweenPath. When I use ShakePosition it temporarily stalls the camera from moving forward while the shaking takes place and then resumes its movement, but is now trailing behind its previous position by several units. Multiple shakes in a row essentially stop the camera from moving anywhere at all. I'd prefer it if I could keep the camera held at its current position(that's constantly moving along the path) and perform the shake around that without stopping.
ShakeRotation has a similar effect except instead of falling behind it seems to be obtaining a final rotation that the shake uses to shake around and align to on completion. While shake is active it will stop keeping up with the current constant orientation until the shake is complete, at which point it resumes but with the new altered rotation.
Should I try to find a way to constantly update the vector3 it's performing the shake around?
Maybe I should just make my own camera shake..
Answer by pixelplacement · Feb 13, 2011 at 09:17 PM
iTween can't move two properties at one time. Try shaking a parented camera and have it's parent follow the path instead of trying to do it all on one transform.
Thanks for the idea pixelplacement. I gave it a shot but it's sort of still having the same problem. I don't remember if it did this before but it's taking the shake settings and seems to be using them as world coordinates even though I set "space" to self. I already wrote my own shake transfor$$anonymous$$g localposition though so it's all good.
I'm still loving iTween. The pathing system is excellent. Will be donating. Thanks for the great pluggin.
Answer by mrFox · Dec 18, 2011 at 12:40 AM
Hey there, i know it's an old question but i had the same problem so i found it and thought i might share the answer.
parenting is the solution as Bob Berkebile pointed out, but it seems that it only works the other way around.
drop the camera into an empty gameobject to parent it and then: let the child (the camera itself) follow it's path and shake the parent.
Answer by Lttldude · Mar 09, 2012 at 06:02 PM
I had the same problem: getting a gameobject to shake while using another iTween function (following a path or moving). The key is parenting. The parent does the movement while the child does the shake. However, I had to do some crafty update, onupdate, and oncomplete functions for it to work. Note: I only needed to have the child follow the parent's y position during the shake. Hope this helps.
`function Start ()
{ iTween.ShakePosition(transform.gameObject, iTween.Hash("x",shakeAmount, "time", duration, "delay",delay,"easetype", iTween.EaseType.easeInOutQuint, "onupdate", "StayWithParent", "oncomplete", "StayWithParent")); }
function Update () { StayWithParent(); }
function StayWithParent() { transform.localPosition.y += transform.parent.position.y - transform.position.y; }`
Your answer
![](https://koobas.hobune.stream/wayback/20220613103433im_/https://answers.unity.com/themes/thub/images/avi.jpg)