Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - SMaton

Pages: [1]
1
DOTween & DOTween Pro / Copy path and correct elapsed time
« on: September 03, 2015, 04:35:10 PM »
Hello everyone,

I'm currently struggling which seemed to be a trivial problem:

I have a game object of a given type that follows a path. The path has been created using this code:

Code: [Select]
       m_currentTween = transform.DOPath(m_currentMove.path, m_speed, PathType.CatmullRom, PathMode.Full3D, 10).SetSpeedBased().SetLookAt(0.01f).SetEase(Ease.Linear).SetUpdate(UpdateType.Fixed).OnUpdate(MoveUpdate).OnComplete(MoveComplete);

Later on in the game, upon an event, I have to change the type of object BUT I have to keep the current path AND the position on the path. So we do this:

Code: [Select]

float _elapsed = m_currentTween.fullPosition;

MoveController headPiece = (MoveController)GameObject.Instantiate(m_headPrefab, nextPos, nextRot);
m_currentTween = headPiece.transform.DOPath(m_currentMove.path, m_speed, PathType.CatmullRom, PathMode.Full3D, 10).SetSpeedBased().SetLookAt(0.01f).SetEase(Ease.Linear).SetUpdate(UpdateType.Fixed).OnUpdate(MoveUpdate).OnComplete(MoveComplete);
m_currentTween.fullPosition = _elapsed;

We also tried Elapsed() and Goto()...

Thing is that the instantiated object does not appear at the exact same position as the original object. In fact, the behavior looks quite random along the path and even leads to a movement which first moves the new object to the starting point of the path.

What would be the correct procedure to actually "transfer" the current path and position on the path to a newly instantiated object?

Best regards,
Stefan

Pages: [1]