Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: OnlineCop on August 13, 2013, 12:19:48 PM

Title: TweenPosition using global position instead of localPosition?
Post by: OnlineCop 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' ?
Title: Re: TweenPosition using global position instead of localPosition?
Post by: ArenMook on August 13, 2013, 08:06:40 PM
There is a "world space" option on the tween.
Title: Re: TweenPosition using global position instead of localPosition?
Post by: OnlineCop 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.  ???
Title: Re: TweenPosition using global position instead of localPosition?
Post by: ArenMook 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.
Title: Re: TweenPosition using global position instead of localPosition?
Post by: Cawas 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
Title: Re: TweenPosition using global position instead of localPosition?
Post by: ArenMook 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... <_<
Title: Re: TweenPosition using global position instead of localPosition?
Post by: Cawas 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.)
Title: Re: TweenPosition using global position instead of localPosition?
Post by: ArenMook on August 30, 2013, 05:13:20 PM
That's not NGUI's repository.