Author Topic: [Potiential feature-request] How do I tween the position relative to a target?  (Read 4224 times)

Emirk

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 2
    • View Profile
Let's say I have a UISprite in the middle of my screen. I'd like to animate this sprite to move from the left side of the screen to the right side - independent of screen pixel width. How do I do that? As I understand it, the current TweenPosition script only animates absolute values. If there's no way to animate an object relative to the positioning of some other object, then the tween position scripts are useless unless you're only targeting an exact pixel resolution.

The new Anchor system is great and it's lets us build UIs that work across different resolutions. When using Unified anchors, one can specify relative to what UIWidget you want to position your element. I'd like something similar for Tweens: The ability to specify from and to percentages relative to a specific UIWidget. That would make various Tween scripts much more useful.

Is there any way to do this today that I'm missing? If not, will it ever be added to NGUI?

Thanks for a great plugin!

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Well, essentially you'd have to calculate the absolute position from your relative thing. Say, you want it to move to another widget with a certain offset - then you need to have a controller script with a reference to that target, and use its localPosition+offset as the target for the tweener.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
You can always use TweenTransform for something like that.