[Open Beta] Procedural On-the-Fly Animation in UE4: iTween!

Hey again, gpvd. You can stop tweens by calling “Stop Tweening by…” and choosing the method of stopping you want. You most likely want to use “stop tweening by tween name” since the object that was tweening was destroyed. You can also pause and resume tweens in the same way.

I considered destroying the tween when the tweening object was destroyed, but there’s really no good way to do that and still allow for event operators to change their tween type and the object they act upon while they’re live. We figured it was better to keep iTween more versatile. However I will keep looking at ways to kill tweens that are no longer necessary if the user wants it :slight_smile:

UE4 can always use more content and plugins. The question is whether or not you need it, and only you can answer that question.

Some people think iTween is superfluous when the interp functions exist, but I have to disagree. Interp is great and it’s even used on the iTween “update” events (Move Update, Rotate Update), but it offers very little control. It’s only one quadratic-ish easetype, it must be called by tick or a timer, has no looping functionality, etc. There’s nothing iTween does that can’t be done through C++ on your own (and almost everything it does can be done in blueprints), it just saves you the time and trouble of setting it up yourself. It does it all while keeping performance costs at a minimum and offering more immediate control.

And at the end of the day, it IS free. :slight_smile:

Tnx for the info, i’ll use stop tween.

Greetz,
G

Hello ,

I think i might have bumped into a bug…
Basicly, when an actor is setup with a rotating tween with a rewind loop, and the actor was destroyed while the tween is still running, the editor crashes.

I tested it on a new project (just like the last time)

Created new blueprint project based of sidescroller, including starter content.
Installed itween as blueprint only.
Added an actor, added a static mesh component to it
, and set the actor up as shown in the image.
Next i set the life of the actor at 3 sec. to make sure that its destroyed before the tweens are complete.
Then hit play, and moments later the editor crashes.

I also did a test by setting the loop type of the move tween to rewind and the loop type of the rotation tween to play once,
but then it also crashes.

The last test what i did was setup the actor with only the move tween and loop type set to rewind.
Also crashed the editor after a while.

Could you be so kind to look into it?

Tnx very much.
Greetz,

G

Interesting! Usually when an actor is destroyed while the tween is running, it simply tries to act upon a nullptr which should do nothing. Looks like we’ll have to check to see if the object we’re tweening still exists before performing the tweening operation. Not a big deal, but is a bit more work than it sounds since we’ll have to check the event type too. But this is on the list of things to fix and is high-priority. Thanks gpvd!

I am trying to get the tween values using “Event on Tween Data tick” event inside by widget but its not firing the event. is how I have setup it up,

Is there something else I need to setup for “Event On Data Tick”?

Thanks,

What exactly are you trying to do? Is the Event On Tween Data Tick in your HUD?

It looks like you’re trying to set a variable local to your HUD blueprint called “Tween Name” to be Alpha Completion (a number between 0 and 1) when the Tween tick message is called. Is that what you’re trying to do?

Yes Event on Tween Data Tick is in the HUD. It works fine for the “Event On Tick” but doesn’t work for the “Event On Tween DataTick”.

Thanks,

I see what you’re doing now, ok. This is intended behaviour. OnTweenDataTick is only called when using a Data Type tween, like Float or Linear Colour or Vector From/To, etc. When doing an Actor Move From/To, OnTweenDataTick isn’t called because there’s no reason to. OnTweenTick is called instead. I know this is hard to figure out without documentation, my apologies. I’m just a one-man team working on iTween since the rest of my coworkers aren’t involved. I’m working on it!

Is there any particular reason you want to call OnTweenDataTick that OnTweenTick doesn’t satisfy?

ohhk, I get it now. There is no particular reason, m just learning the tool using different functionality and understanding how things works.
Thanks for replying so quickly and awesome job on getting iTween functionality to Unreal Engine 4.

Thanks,

Awesome :slight_smile: I think I’ll go ahead and consolidate OnTweenDataTick into OnTweenTick by collapsing all the Data values into a struct just to avoid confusion.

,

I just tried to compile my app for iOS since adding itween and I get a compilation error =(

iOS is my main platform so I can’t really use itween if it can’t work on there…

Any tips?

–EDIT
Looking into this…SetActorLabel is only available in the editor, not packaged builds…so this call should probably be wrapped insomething but I’m not sure if that would break anything so I’ll wait to see what you say first.
Also, it appears iOS’s compiler doesn’t like having the decrements assignment inside a computation sequence like that.

Hey I have to ask, are you deploying from Windows or Mac? As of right now projects with C++ can not be deployed to iOS from windows.

I will take a peek at what can be done on iTween’s end, though. I’ll wrap SetActorLabel() if in editor or see what can be done with FName. But deleting that function and its call (in iTweenEvent.cpp inside InitEvent()) won’t hurt anything, that’s really only for reference. As for the math compile errors… geeze. What a high-maintenance compiler. Total diva. Fine iOS, I’ll dumb the math down JUST FOR YOU. :cool:

Let me know if removing the NameEventActor() function works for you when building.

Actually, they can be :), with ‘remote’ building. I develop on windows, but using UE4’s remote building I am able to compile on a mac laptop I have. Its only in the github version though.

Well look at that!

I wrapped SetActorLabel and I’m working on some options for the math troubles, but this is being done in a largely unfinished build that I won’t be able to get out for a while. It needs a ton more testing. Did you have any luck removing the NameEventActor function? As for the math, if you aren’t using Ease In Elastic or Ease In and Out Elastic (and let’s be honest, who is?) then you can simply remove their case entries from the switch inside of the GetAlphaFromEquation function.

actually…I am using them lol, I can probably fix the math on my local machine pretty easily. I’ll spend some time on this tomorrow. I was mostly worried about that label stuff, since I wasn’t sure if it was being used for anything, but if not, I’ll probably just try commenting it out.

Haha… of course! The good news is that Ease In Elastic is an easy fix:

					  value -= 1;
					  return -(a * FMath::Pow(2, 10 * (value)) * FMath::Sin((value * d - s) * (2 * pi) / p)) + start;

But it’s not as easy to fix Ease In and Out Elastic. I’m still trying find a way that will work. If you find it before me, please share the knowledge! If we can’t figure it out, I’d recommend you daisy-chain an Ease In Elastic into an Ease Out Elastic when it completes.

You can absolutely just comment out the NameEventActor() method since it does nothing but provide a reference name. This name is never used by iTween beyond that.

I was able to get this compile…unfortunately I am having some issues with Blueprint Widgets, so I’ve decided to move straight to Slate, if I use iTween on the C++ side, can I use the same blueprint functions pretty safely?

Great news! May I ask what you did as far as the EaseInAndOutElastic easetype equation?

Most all of the iTween functions do work in C++, but the UMG RT functions I’m not so sure on. My experience with Slate is limited, but I believe UWidgets are wrapped Slate Widgets, so the type is different. As far as I know, Render Transforms are UMG-specific functionality as well, but I could be wrong about that. If I am, that’s fantastic, but I really don’t know.

Nonetheless, you can use the Float From/To and Vector2D From/To functions to drive Slate widgets.

I didn’t look to far into Elastic in and out, I just pulled out the value -=1 to get it to compile.

The basic issue I have found, is slate objects (SCompositeWidgets) are not Uobjects, therefore I can’t use your interface (extending from it is only possible from things that inherit from UObject). I think I would need to create a second interface without the GENERATED_INTERFACE_BODY but I’m not sure if that is possible or how much work that would mean. Otherwise, I could try to write my Slate Objects with the UWidgets that UMG use, but there isn’t really any documentation on using UMG C++ yet, and it seems I would be creating alot of unnecessary code. So I’m still trying to figure out how I should handle this.

edit:

Nope, going to be more work then I thought, as the parameters accept the object as a UObject in the first place, I’m just going have to find a way to either wrap my widgets in dummy u objects or something.

You’re right, you’d have to mickey-mouse some kind of interface solution. Why are you opting for Slate, though? Is there some functionality UMG doesn’t provide?