Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: grofie on July 11, 2014, 03:18:43 AM

Title: TweenPosition: moving to another gameobject
Post by: grofie on July 11, 2014, 03:18:43 AM
Hey guys,

I feel quite stupid but i cannot get the position tweener run like I want:
  1. TweenPosition.Begin(m_FlyingGeleeEffect, m_FlyGeleeEffectLength, m_GeleeEffectTarget.position);
Should simply move the m_FlyingGeleeEffect gameobject to the target position (a transform in another branch under the gui camera and layer). Instead its moving super little, in the wrong direction.

I played arround with camera matrixes but nothing works.

When i simply set
  1. m_FlyingGeleeEffect.transform.position = m_GeleeEffectTarget.position;
The effect lands on the right position, so the transforms itself are not the problem.

What am I missing? Thx in advance..
Title: Re: TweenPosition: moving to another gameobject
Post by: grofie on July 11, 2014, 03:43:58 AM
Hm, looks like the problem was the worldspace option:

Using
  1. TweenPosition.Begin(m_FlyingGeleeEffect, m_FlyGeleeEffectLength, m_GeleeEffectTarget.position).worldSpace = true;
Worked for the target position, but fu**s up the start position.

In the end I had to use
  1. TweenPosition l_TweenPosition = m_FlyingGeleeEffect.GetComponent<TweenPosition>();
  2. l_TweenPosition.worldSpace = true;
  3. l_TweenPosition.from = m_FlyingGeleeEffect.transform.position;
  4. l_TweenPosition.to = m_GeleeEffectTarget.position;
  5. l_TweenPosition.duration = m_FlyGeleeEffectLength;
  6. l_TweenPosition.enabled = true;
  7. l_TweenPosition.PlayForward();
with a TweenPosition already on the gameobject.

Would be very nice, if TweenPosition.Begin() would accept worldSpace as an parameter, so it can init in the right way.  ::)
Title: Re: TweenPosition: moving to another gameobject
Post by: ArenMook on July 11, 2014, 08:07:55 PM
This happens because when you call TweenPosition.Begin, it's in local space. You change it to world space afterwards, but the "form" and "to" values are already set to local values. I'll add an extra function that accepts the world space as an optional boolean parameter.
Title: Re: TweenPosition: moving to another gameobject
Post by: grofie on July 14, 2014, 04:09:28 AM
This happens because when you call TweenPosition.Begin, it's in local space. You change it to world space afterwards, but the "form" and "to" values are already set to local values. I'll add an extra function that accepts the world space as an optional boolean parameter.

Thx Aren,
that would be exaclty what I was looking for. ;D