Author Topic: TweenPosition: moving to another gameobject  (Read 3463 times)

grofie

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 17
    • View Profile
TweenPosition: moving to another gameobject
« 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..

grofie

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 17
    • View Profile
Re: TweenPosition: moving to another gameobject
« Reply #1 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.  ::)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TweenPosition: moving to another gameobject
« Reply #2 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.

grofie

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 17
    • View Profile
Re: TweenPosition: moving to another gameobject
« Reply #3 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