Author Topic: TweenPosition using global position instead of localPosition?  (Read 5309 times)

OnlineCop

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 51
    • View Profile
TweenPosition using global position instead of localPosition?
« on: August 13, 2013, 12:19:48 PM »
I've got multiple transforms positioned around my environment: some are sources (where the TweenPosition tween begins) and the others are destinations (where the TweenPosition tween ends). I randomly choose one source and one destination Transform, instantiate my object, and call:
  1. TweenPosition tween = TweenPosition.Begin(newMonster.gameObject, 5.0f, randomDest.transform.position);
  2. tween.from = randomSource.transform.position;
  3. tween.to = randomDest.transform.position;
  4.  
This appears to work correctly when the randomSource and randomDest are located under the same parent, with the same scale.

It does not work correctly if they are in different parents, with different scales.

If I modify NGUI/Scripts/Tweening/TweenPosition.cs to use '.position' instead of '.localPosition', it appears to work fine when this is the the case.

Is there a reason why '.localPosition' is being used instead of '.position' ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TweenPosition using global position instead of localPosition?
« Reply #1 on: August 13, 2013, 08:06:40 PM »
There is a "world space" option on the tween.

OnlineCop

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 51
    • View Profile
Re: TweenPosition using global position instead of localPosition?
« Reply #2 on: August 14, 2013, 09:41:23 AM »
Is this "world space" option available on TweenPosition.cs itself, in its parent UITweener.cs, or its parent IgnoreTimeScale.cs ?

I've showing a Debug view of the Inspector, and I haven't found any mention of "world" or "local" in either of those files.  ???

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TweenPosition using global position instead of localPosition?
« Reply #3 on: August 15, 2013, 07:26:28 AM »
Oh wait I was thinking of the SpringPosition.

Simplest thing you can do is just write your own tween. Take TweenPosition (copy/paste it), and modify it to use 'position' instead of 'localPosition'. It'll take you two minutes tops.

Cawas

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
  • fucking programmer
    • View Profile
Re: TweenPosition using global position instead of localPosition?
« Reply #4 on: August 29, 2013, 06:35:20 PM »
First time posting here, so let me just say this before anything: NGUI must be the best framework (among 9 or 10) I've ever used on Unity (or maybe anywhere else!). It's freaking awesome! And, despite having (hateful) forums (instead of Q&A) for support, they're still very helpful! Thanks a lot for all that!

---

Aren,

I think OnlineCop's question is still unanswered here. Is there any reason why '.localPosition' is being used instead of '.position'?

I'm with same issue and already solved it by patching the file, but I wonder if this shouldn't be updated on NGUI. And, if it should, then I'd have another question: Is there a git I can send a pull request? :-P

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TweenPosition using global position instead of localPosition?
« Reply #5 on: August 29, 2013, 07:15:51 PM »
NGUI is hosted on bitbucket, and I accept pull requests there. However bitbucket access is given to Pro users... <_<

Cawas

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
  • fucking programmer
    • View Profile
Re: TweenPosition using global position instead of localPosition?
« Reply #6 on: August 29, 2013, 11:04:07 PM »
Well, then... I hope the following "quote" I just made up may complete most of the blanks on yours:

Quote
No special reason it's using one or the other position. We use all other Transform attributes as local, so it was position as well. Making a patch to this is on the to do, but simply haven't been done and has no priority. So, yeah, we accept pull requests but you can't do it with a free bit bucket account. Sorry.

If that's right, attached there's the file in any case. ;-)

(Plus, I couldn't find TweenPosition.cs under https://bitbucket.org/tsgstudio/rngui to even try.)
« Last Edit: August 29, 2013, 11:15:08 PM by Cawas »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TweenPosition using global position instead of localPosition?
« Reply #7 on: August 30, 2013, 05:13:20 PM »
That's not NGUI's repository.