playMaker

Author Topic: How to Turn Off iTween Easing in MoveTo [CLOSED]  (Read 13563 times)

memetic arts

  • Full Member
  • ***
  • Posts: 141
How to Turn Off iTween Easing in MoveTo [CLOSED]
« on: June 24, 2013, 04:33:52 AM »
Hi All -

I'm moving several objects on a spline using the iTween MoveTo action.  I would like the objects to move at a constant speed, without easing of any type.  I currently have the ease type set to "Linear", which I understood from iTween's docs to be the equivalent of "off".

For some reason, though, the objects slow way down when they move around curves, and speed up again on straightaways.

Is there a parameter that I'm missing?

Though not exactly the same issue, it sounds familiar to this, for which no solution was posted:

http://hutonggames.com/playmakerforum/index.php?topic=2401.msg10659#msg10659

Thanks!
« Last Edit: June 29, 2013, 08:57:41 PM by memetic arts »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to Turn Off iTween Easing in MoveTo
« Reply #1 on: June 24, 2013, 06:23:47 AM »
Hi,

if you build a spline with only two points, do you get the easing?

bye,

 Jean

memetic arts

  • Full Member
  • ***
  • Posts: 141
Re: How to Turn Off iTween Easing in MoveTo
« Reply #2 on: June 24, 2013, 07:03:41 AM »
Yes . . . there is a slowing down and a pause at each end before the object returns down the spline.  It should just be ping-ponging back and forth between the two points.  (and i tried both loop and ping-pong loop types).

thx.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to Turn Off iTween Easing in MoveTo
« Reply #3 on: June 24, 2013, 07:05:08 AM »
Hi,

 Let me contact the author. I recall I bumped into this. I know "curvy" does it very well tho. and the author is into porting this to playmaker, so let me know if you want to go that way.


bye,

 Jean

memetic arts

  • Full Member
  • ***
  • Posts: 141
Re: How to Turn Off iTween Easing in MoveTo
« Reply #4 on: June 24, 2013, 08:58:51 AM »
Thanks, Jean. 

Actually, Mr. Berkebile did provide an answer to the same question over in Unity Answers (not asked by me!):

http://forum.unity3d.com/threads/69933-iTween-Turn-of-Easing-How

So that was no help . . . unless it actually does work outside of the PlayMaker framework, which will be my next test:  a simple, isolated, script-only tween.  I'll let you know how it goes.

Thanks again!


Edit:  Ok, so I did the quick iTween-without-PlayMaker test, and the linear easetype does in fact work as it should -- no accel/decceleration.  I used this code to test:

Code: [Select]
iTween.MoveTo(gameObject,iTween.Hash("path",path,"time",3,"easetype",iTween.EaseType.linear,"looptype",iTween.LoopType.pingPong));
So I hate to say it, but there must be something in the Action that's getting lost in translation . . . I gave it a quick look and didn't see anything obvious, but will keep on it.

« Last Edit: June 24, 2013, 09:22:34 AM by memetic arts »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to Turn Off iTween Easing in MoveTo
« Reply #5 on: June 25, 2013, 03:00:31 AM »
Hi,

 uhm, I tested using playmaker testlab scene "MoveTo_Path" and setting the ease to linear did the trick

maybe you can share the scene you are testing with, then I can see what's wrong and address it.

bye,

 Jean

memetic arts

  • Full Member
  • ***
  • Posts: 141
Re: How to Turn Off iTween Easing in MoveTo
« Reply #6 on: June 26, 2013, 11:06:55 PM »
That would be awesome, Jean, thanks for offering. . . I've just got to trim the scene down to the essentials and I'll send you a package in a pm.

Cheers

memetic arts

  • Full Member
  • ***
  • Posts: 141
Re: How to Turn Off iTween Easing in MoveTo
« Reply #7 on: June 27, 2013, 12:41:00 PM »
Ok, so I just stumbled on a few posts/articles that confirm the issue -- it's NOT a PlayMaker issue at all, but rather has to do with how iTween deals with paths.  It makes logical sense, but unfortunately, was not handled out-of-the-box.  There are published solutions, and I'm including links.  While it would be great if the solution could somehow be baked-in to the PlayMaker/iTween Action library, at my current level of expertise, I am not the guy to do it.  And it looks like it could be a fairly significant little project.

Anyway, the basic 'problem' is that in an iTween path, speed and time are dependent on the distance between two points/nodes -- so if your nodes aren't equidistant, the speed across the entire path will vary from node-to-node.  Makes sense, right?  But the result is undesirable in many cases.

Here are some links that expound on both the issue and solutions:

http://vanstrydonck.com/working-with-itween-paths/

http://forum.unity3d.com/threads/182693-Getting-constant-speed-from-iTween-%28Solution-Included-c-files-attached%29

and another thread on Unity Answers with some less efficient solutions, but may be of interest (check out response from Felipetnh and the link to his C# file on MediaFire):

http://answers.unity3d.com/questions/194671/itween-even-velocity.html?page=2&pageSize=5&sort=votes

So there it is . . . maybe there's a brave soul out there who can codify all of this into an addendum to the PM/iTween library.  :)

Cheers


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to Turn Off iTween Easing in MoveTo
« Reply #8 on: June 27, 2013, 01:58:18 PM »
Hi,

 As I said, I would actually recommand you pick a new tweening library that offer this out of the box and proper. Have you looked around already?

I'll study the solution provided, but I am still unsure this is the right way to go, since it's know that iTween is not really suitable for mobile and performance senstive context, while new tweening and spline libraries do offer better perfs.

bye,

 Jean

memetic arts

  • Full Member
  • ***
  • Posts: 141
Re: How to Turn Off iTween Easing in MoveTo
« Reply #9 on: June 27, 2013, 02:08:50 PM »
OH!!  I actually missed that you'd made that recommendation, sorry.  I had been using iTween before I had PlayMaker, and had thought it was the go-to solution - and of course was happy to find the integration with PM.  Anyway, I'll do the due diligence, then, and will research other options.

Wasn't aware of the mobile issue with iTween either, thx for the heads-up.

memetic arts

  • Full Member
  • ***
  • Posts: 141
Re: How to Turn Off iTween Easing in MoveTo
« Reply #10 on: June 29, 2013, 08:48:16 PM »
Jean, thanks for setting me on the right path (no pun intended) . . . I checked out Curvy, which looks great, but then I remembered that Vectrosity -- which is what I'm using to generate the actual spline -- also comes with a spline-follow script, so rexamined that. And guess what -- it explicitly moves objects at a constant speed.

The best part?  It's just a few lines of code:

Code: [Select]
do{
   for (var dist = 0.0; dist < 1.0; dist += Time.deltaTime*speed) {
       obj.position = myVectorLine.GetPoint3D01 (dist);
       yield;
    }
} while (loop);

Since that original block appears in the same file as the spline generation code, I pulled it out into a new script that I could attach to the prefabs that move along the spline, which required a slight modification to enable cross-script access.  Basically the same thing, except myVectorLine becomes FindObjectOfType(scriptName).myVectorLine

Of course the funny part now is that during the course of trying to resolve this, I've actually grown to like the quasi-easing effect, LOL.

And I might still go in for Curvy, especially since they've just published some PM Actions, and, as you said, it's optimized for mobile.  The Magic Box plugin looks pretty awesome too . . .

EDIT / NOTE: I'm declaring this "Closed" and not "Solved" since a solution was discovered, but not one that directly addresses the actual issue.  I found a way to achieve constant speed, but not with iTween.
« Last Edit: June 29, 2013, 09:00:33 PM by memetic arts »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to Turn Off iTween Easing in MoveTo [CLOSED]
« Reply #11 on: July 01, 2013, 01:32:09 AM »
Hi,

 Very good. I am glad you found your way around this. Thanks for sharing all this, it's very valuable indeed!

bye,

 Jean