playMaker

Author Topic: Altering speed of an object doing iTween Move To  (Read 2338 times)

topscore1632

  • Playmaker Newbie
  • *
  • Posts: 19
Altering speed of an object doing iTween Move To
« on: October 20, 2015, 10:58:27 AM »
Hi,

I've got an object moving along a path using iTween Move To. It moves from node to node perfectly, no problems there.

I want to be able to animate the speed of the movement when a key is pressed - I've therefore set a global Float called 'MoveSpeed' which I then animate from 5 down to 0 using an Animate Float action.

The MoveSpeed float value changes correctly over time, however the speed of the moving object never alters. It's almost like once the iTween starts, the values cannot be changed. Is this the case?

Thanks in advance for any help!

ManicMinerUK

  • Junior Playmaker
  • **
  • Posts: 51
Re: Altering speed of an object doing iTween Move To
« Reply #1 on: October 21, 2015, 08:55:54 PM »
That is absolutely the case

I've had to deal with this in the past, and so you have a few options...

One way is to do the movement with translate instead of itweens... This might or might not be an option, depending on the kind of movement you are looking for and how this movement relates to the rest of your project (it can be difficult to exactly recreate the effect of speed=5 on an itween with axis translations)

Alternatively, you can cancel and restart the itween each time the speed changes - this only works if you are changing it in steps though, as stopping and starting the itween every frame is likely to do your framerate no favours :)

topscore1632

  • Playmaker Newbie
  • *
  • Posts: 19
Re: Altering speed of an object doing iTween Move To
« Reply #2 on: October 22, 2015, 10:35:34 AM »
Hmmm that explains things, and has saved a lot of head banging.

I think your second suggestion will work best for me, I'll give it a go.

Thanks!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Altering speed of an object doing iTween Move To
« Reply #3 on: October 22, 2015, 01:58:28 PM »
Hi,
you might consider using dotween

itween is laggy so if you want to use every frame you might get problems

you can see the difference here