Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

iTween: Parented Motion Paths

Discussion in 'Scripting' started by dashperiod, Sep 2, 2011.

  1. dashperiod

    dashperiod

    Joined:
    Sep 2, 2011
    Posts:
    2
    To get to the point - fundamentally my question is: Is it possible to create an iTween path parented under a GameObject and animate it in the local space of that GameObject?

    I've been working with iTween alot lately and I love what it does, but there is one use case that I haven't been able to figure out how to implement. Namely, that would be parenting an iTween path to a GameObject and and then having the iTween path animate in local space rather than world space.

    From what I've seen via documentation and experimentation, iTween seems to only want to animate in world space, and functions based on world coordinates. Even when you set the `islocal` property to `true` in MoveTo, it seems to just reinterpret a transform's `localPosition` property into a world coordinate.

    To get a better idea of why one would want to do this, here's one practical application:

    Fixed-Camera animations. Let's say you have a racing game, where you have 2 mount points for a camera parented to a car - one facing forward behind the car, and one rear view from in front of the car. If we wanted to animate from one point to the other, say to have the camera swing around the side of the car to end up at the front, using an iTween path parented to the car's origin would be a great option. The path moves with the car, and then you set the path points in local space relative to the car's origin.

    iTween would be the perfect tool for this in Unity, it gives great flexibility for tweaking and/or randomizing camera animation. Perhaps I haven't dug deep enough to find the solution....or maybe iTween doesn't support what I'm looking for. Does anyone know which is the case? :)

    Thanks in advance.
     
  2. handsomePATT

    handsomePATT

    Joined:
    Nov 30, 2010
    Posts:
    574
    I had this problem to. I got it working by creating empty gameobjects where each node was of the path, and then in update set each node position to the transform of the gameobject. It worked but not very well haha. I ended up writing my own.
     
  3. dashperiod

    dashperiod

    Joined:
    Sep 2, 2011
    Posts:
    2
    Yea, I tried that too, and it works'ish but it's not ideal...because if your parent object is going like 90mph twisting/turning through a level, if the animation takes more than 1 frame, the object on the iTween path ends up at the position of your placeholder gameobject from whatever frame the iTween.MoveTo was called.

    So if you set the `time` value of your MoveTo to something like 0.5 secs, that's a pretty quick camera move, but if you're going at say 60fps, then at the end of the animation you're going to end up at whatever the placeholder's world position was 30 frames ago.

    Unless I'm mistaken, you can't update the path of a MoveTo once it's been excecuted right?

    Out of curiosity, what alternative solution did you end up writing on your own?
     
  4. handsomePATT

    handsomePATT

    Joined:
    Nov 30, 2010
    Posts:
    574
    yeah it definately wasnt a usable solution :p and I basically do the same thing, I had to put each node separetly and drag them into my script, but it will go from one to the next and looks really good.
     
  5. Suminsky

    Suminsky

    Joined:
    Aug 11, 2011
    Posts:
    50
    I just want to say that I downloaded iTweens looking for this exactly functionality, relative camera movements. If anyone knows of a working solution for this, please, share.
     
  6. olivier_henley

    olivier_henley

    Joined:
    Aug 14, 2012
    Posts:
    7
    Same problem here.
     
  7. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    You should contact bob from pixel placement. But as far as I know, making a path a child of x object, then moving x object has no effect on the path. There are a few things about iTween path that I do not like, feature wise, and that is one of them.