Can a DOTweenPath from a component be added to a Sequence?
« on: January 11, 2016, 07:50:19 PM »
Hi, I've some DOTweenPath components in gameobjects and I would like to play them in a sequence, can i use this?

Code: [Select]
sequence.Append(path.tween);

path is my DOTweenPath component reference.
Do I need to do this before use it? (i'm going to reuse it so i switch off the autokill and autoplay buttons in editor).
Code: [Select]
path.DOPause();
path.DORestart();

because i have this error if i try to do that:
Code: [Select]

Unhandled Exception: System.ArgumentException: Key duplication when adding: Void DORestart(Boolean)

  at System.Collections.Hashtable.PutImpl (System.Object key, System.Object value, Boolean overwrite) [0x00000] in <filename unknown>:0

  at System.Collections.Hashtable.Add (System.Object key, System.Object value) [0x00000] in <filename unknown>:0

  at Mono.CSharp.MethodGroupExpr.OverloadResolve (Mono.CSharp.ResolveContext ec, Mono.CSharp.Arguments& Arguments, Boolean may_fail, Location loc) [0x00000] in <filename unknown>:0

  at Mono.CSharp.Invocation.DoResolveOverload (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0

  at Mono.CSharp.Invocation.DoResolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0

  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, ResolveFlags flags) [0x00000] in <filename unknown>:0

  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec) [0x00000] in <filename unknown>:0

  at Mono.CSharp.ExpressionStatement.ResolveStatement (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0

  at Mono.CSharp.StatementExpression.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0

  at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0

  at Mono.CSharp.If.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0

  at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0

  at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0

  at Mono.CSharp.Block.Resolve (Mono.CSharp.BlockContext ec) [0x00000] in <filename unknown>:0

  at Mono.CSharp.ToplevelBlock.Resolve (Mono.CSharp.FlowBranching parent, Mono.CSharp.BlockContext rc, Mono.CSharp.ParametersCompiled ip, IMethodData md) [0x00000] in <filename unknown>:0

Internal compiler error at Assets/Scripts/GameController.cs(594,10):: exception caught while emitting MethodBuilder [GameController::getPerfectShotRepresentation]


Can I modify the latest point of the path and re-evaluate it before play?
something like...
Code: [Select]
path.GetDrawPoints()[path.GetDrawPoints().Length - 1].Set(ballDestiny.x, ballDestiny.y, ballDestiny.z);
« Last Edit: January 11, 2016, 07:58:42 PM by juaxix »

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Can a DOTweenPath from a component be added to a Sequence?
« Reply #1 on: January 11, 2016, 08:12:45 PM »
Hi!

I can't test it right now, but you should definitely be able to add a path tween to a Sequence. To do that though, you have to be sure it didn't start, otherwise it won't be allowed (for example, calling DORestart actually starts the path so you shouldn't do that). Just uncheck AutoPlay in the Inspector and everything should work.

About changing a path's waypoint at runtime, that can't be done, sorry. A DOTweenPath's path is pre-calculated in the editor to make things faster, so it can't be changed later. Still, you could get the path's waypoints and create a completely new path tween using DOPath.

Cheers!

Re: Can a DOTweenPath from a component be added to a Sequence?
« Reply #2 on: January 11, 2016, 08:18:25 PM »
Yeah, SMART. Daniele, problem solved  ;D i just do this: ballTransform.DOPath(..) ,where the "..." are the DOTweenPath component (configured in the scene) params , saving the points in an Vector3[] aux and modified the latest point, super fast ;)
Thanks
Hi!


Cheers!

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Can a DOTweenPath from a component be added to a Sequence?
« Reply #3 on: January 11, 2016, 08:24:15 PM »
Great! :)

Re: Can a DOTweenPath from a component be added to a Sequence?
« Reply #4 on: January 17, 2016, 10:33:58 PM »
UPDATE:
I fixed it! it was the wps var, thanks  8)
Hey , testing this code on android

Code: [Select]
            Vector3[] pathPoints = dopathComponent.GetDrawPoints();
            twBallMove = theBall.DOPath(pathPoints, dopathComponent.duration, dopathComponent.pathType, dopathComponent.pathMode, dopathComponent.pathResolution).SetAutoKill(true);

I had this error
Code: [Select]
W/Unity   (22635): DOTWEEN :: Draw points not ready yet. Returning NULL
W/Unity   (22635): 
W/Unity   (22635): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)
W/Unity   (22635):
I/Unity   (22635): NullReferenceException: Object reference not set to an instance of an object
I/Unity   (22635):   at GameController.getPerfectShotRepresentation (DG.Tweening.Sequence& seq, Boolean usePlayerMovement) [0x00000] in <filename unknown>:0
I/Unity   (22635):   at GameController.onPlayerKickBall () [0x00000] in <filename unknown>:0
I/Unity   (22635):   at Player.Update () [0x00000] in <filename unknown>:0
I/Unity   (22635): 
I/Unity   (22635): (Filename:  Line: -1)
I/Unity   (22635):

should i have to wait before points to be generated? :|

I understand you can't use the drawPoints in production, i was confused because i think this function will work out of the editor, but it clearly says that it's for unity editor, so, how can i get the waypoints?, i think it's the wps  variable.
« Last Edit: January 17, 2016, 11:31:04 PM by juaxix »