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

Hello , I am trying to use Itween to move a train engine/cars combo along a spline to follow as if they were connected. I read the following directions you gave below some time back on the subject, but I am having a bit of a hard time following (due to my lack of experience). Would it be possible to elaborate a bit further on these directions to help me along? Right off the bat I am a bit confused about how to implement iTInterface. Thank you so much in advance and thank you for making this amazing plugin!!

"For right now, you can do all that stuff by using the OnTweenUpdate interface event. OnTweenUpdate is called after all other tweening operations, so you can add transformations in this event and you shouldn’t have any issues.

-Implement iTInterface in a blueprint.
-When you call iTween, make sure you give your tween a unique name and set the blueprint that implements the interface as the “OnTweenUpdateTarget.”
-Go to that target blueprint and add an event called “OnTweenUpdate.”
-From , drag out of the tween name input and do a switch on name. Set one of the outputs to be your tween’s name. This is why I encourage unique names so that whatever you call only reacts to that specific tween.
-Now you can apply extra transformations. In the case of incorrect orientation, you can get the actor’s rotation and invert it then set the rotation to be the inverted one you just calculated. In the case of the trains, you can run 3 tweens all off of one spline then OnTweenUpdate you can set its position to be its current position + the transform direction’d additional position."

Crash using latest

Edit: I found the solution - I had two tweens set up to run on the same object (opening and closing a menu) and hadn’t implemented a check to see whether one had finished before trying to run the other. (Knew it would be a dumb mistake!) That left me with two tweens trying to access the same AitAux object at once which crashed the program.

Ok, this is probably a newbie mistake somewhere, but I’m getting constant crashes trying to use the latest iTween on Unreal 4.15 to tween a vector2D to change a UMG widget slot size. I’m working entirely in Blueprint for this widget but the project is mixed BP and code.

The issue is that I can set up the Blueprint, have everything working nicely, and then when I close and re-open the BP I get an Access Violation crash pointing at iTween.cpp line 88:
aux = (AiTAux*)(GetWorldLocal()->SpawnActor<AiTAux>(AiTAux::StaticClass(), params));

I recreated the BP and it looks like this:

Can anyone point out where I’m going wrong?

Hey Alexaendergfx! Thanks for writing. You can certainly use iTinterface, but it’s the old way of doing things. I added a much easier way of doing things using delegates last year, I’d really recommend using that system instead. I outlined a scenario in a post on the last page, I’ll quote it below so you can take a quick look. Basically, you set the object that has a certain function on it then specify the function name and the plugin will call that function on that object. You can get tween information from the return value from the iTween call, as shown in the screenshot.

Anything you can do with iTinterface can be done with this method and is faster and more convenient :slight_smile: That said, you may have to think around your original design, it all depends on what you’re trying to do. What’s your program flow?

Hey EmzDickson, I’m really glad you found the solution to this crash, but by all means this shouldn’t happen. If iTAux exists, it should just use the one that exists. If it doesn’t, it should create it. This is a big problem! I wasn’t able to repro it on my machine however, any chance you can show me the stack trace? I want all the logs you have if you can manage it :slight_smile:

Thank you so much 
I am creating a railroad train system for my project. I am hoping to move numerous cars behind the engine using iTween and be able to create switches to change to different splines for branches of the railroad. I will definitely try out your new system! Thanks again for responding!!!

Awesome! Let me know if this works out for you or you have any questions!

Update 23 (Mar 10 2017)(Recompile for 4.15):
<ue4 for iTween c++ example demo> Do you have it?
<ue4 for iTween c++ example demo> down url?

Hello!
Why is the orient to path orienting to 2 vertices ahead?

Video :

It has some bugs, is not possible to build the game, neither compile the plug in

Hi, how can i change the move speed from (keypress) event? I want to slow down and stop actor not just stop.

Hi ,after installed the iTween for UE4,my project could’t be package to windows

There is no example demo just yet. I have been working on a feature demo in my spare time, but it takes a backseat to fleshing out the actual plugin, which in turn takes a backseat to projects that pay the rent :slight_smile:

Because when I wrote it I knew little about splines - it’s on the todo list for a revamp using time/duration/distance. In the meantime you can pull off the return value of the tween, get its alpha ( a normalized number between 0 and 1 that tells you how far along the tween is) and multiply it by the spline’s duration then get rotation along spline at time using that value and set it onTweenUpdate to get an accurate rotation. This does not account for any kind of smoothing however, but you can use RotateUpdate for that if you want to.

Those of you having trouble packaging the game, please try this build instead. I’m not actually 100% sure which files need to be included with a plugin in order for everything to work, so I stripped out a number of them I thought wouldn’t be necessary for file size reasons. This build includes everything and as a result is somewhat large, but I tested it this morning and was able to successfully package for Win32, Win64, Android and HTML5. Failing that, you may need to recompile it yourself or add it to your game’s source.

Hey Hermyth, when you create a tween you get an iTweenEvent return value - pull out of this and set the TickTypeValue variable on it directly. You may also want to try explicitly stopping the tween then creating a new tween from its current position/rotation/scale to a new position/rotation/scale where you want it to actually end up stopping. So KeyPress > StopTweeningByName > Start new Tween on same object from current position to stopping position.

Hey, , thought I’d mention that there are some code base warnings when building the plugin for 4.16:

\Plugins\iTween v0.8.7\iTween\Source\iTween\iTween.Build.cs(7,12) : warning CS0618: ‘UnrealBuildTool.ModuleRules.ModuleRules()’ is obsolete: ‘Please change your module constructor to take a ReadOnlyTargetRules parameter, and pass it to the base class constructor (eg. “MyModuleRules(ReadOnlyTargetRules Target) : base(Target)”).’

\Plugins\iTween v0.8.7\iTween\Source\iTween\iTween.Build.cs: warning: Module constructors should take a ReadOnlyTargetRules argument (rather than a TargetInfo argument) and pass it to the base class constructor from 4.15 onwards. Please update the method signature

\Plugins\iTween v0.8.7\iTween\Source\iTween\Private\iTweenEvent.cpp(2723): warning C4996: ‘UEnum::GetEnumName’: GetEnumName is deprecated, call GetNameStringByIndex instead Please update your code to the new API before upgrading to the next release, otherwise your project will no longer compile.
C:\Program Files\Epic Games\UE_4.16\Engine\Source\Runtime\CoreUObject\Public\UObject/Class.h(1773): note: see declaration of ‘UEnum::GetEnumName’

Ah, thank you tosith. I have updated the plugin for 4.16 - it should be 4.17 compliant no problem when the time comes. 's the download for the updated plugin, compiled for 4.16: Mega

I think I found a bug,

doing:

if (tweenpos != NULL)
tweenpos->EndPhase();

tweenpos = UiTween::ComponentMoveFromToSimple(*FString::Printf(TEXT(“moveAvatarHead_%s”), *GetName()), mycamera, mycamera->GetComponentLocation(), camerapos, CoordinateSpace::world, false, 1.0f, easeOutQuadratic);

Properly finishes the tween and creates another.

But doing:

UiTween::StopTweeningByTweenName(*FString::Printf(TEXT(“moveAvatarHead_%s”), *GetName()));
UiTween::ComponentMoveFromToSimple(*FString::Printf(TEXT(“moveAvatarHead_%s”), *GetName()), mycamera, mycamera->GetComponentLocation(), camerapos, CoordinateSpace::world, false, 1.0f, easeOutQuadratic);

On some cases stops the previous tween but do not create another one.

Hi ,

Just reporting a few crashes we’ve seen.

The first is null ref exception in [FONT=Courier New]UiTween::SpawnEvent(AiTAux* aux), where it doesn’t check if the player controller is null before trying to get its pawn.
I’m not sure when/why there wouldn’t be at least one player controller, but we managed to have it happen a few times (maybe when PIE is being torn down?)

Another crash/hang that happens a few times a week is in [FONT=Courier New]UITween::StopTweeningByEventReference(AiTweenObject* object), where Array complains that the length of the currentTweens array changed during the for each loop

This one doesn’t always cause a crash, but will at least hang of a couple of seconds. I seemed to be able to fix by just not calling [FONT=Courier New]EndPhase() inside the loop itself.

On a related note - have you thought about putting iTween on GitHub so we could post issues there and possibly submit PR’s to save you some time? The email notifications would be a lot better than too :slight_smile:

Anyway, thanks!
Geordie

Edit: Just found another bug I think? Our game uses a lot of slomo’s, and so UI animations often need to ignore time dilation.
But I discovered that tweens that played while the global time dilation was eg. 0.1, would actually play significantly faster than they were meant to.
I had a look through the iTween code, and it seemed like the time dilation was actually being compensated for twice - first by setting a CustomTimeDilation on the tween event actor, and then again in the event’s Tick?
Commenting out the actor’s CustomTimeDilation (so just relying on compensation during Tick) seemed to fix.
(I think using Tick to compensate is probably more flexible since the time dilation may change while the tween is running, so setting it once up front wouldn’t actually “ignore” it properly)

Hiya !

Thanks for the great plugin,

Just got back from a long halt in my game, and updated from UE 4.14 to 4.16 and the plugin too. I can’t see any errors, but in an Android packaged build, no tweens seem to work at all anymore? I’ve tried with easing and without, and couldn’t get anything rolling. It works in the editor though? I’d appreciate if you have any insight of whats going on


Have a great week,

Hi! Thanks for this plugin! I sone of the best out there!
I just need an answer for a stupid question. I’m using Itween within a Function and I can’t use delay node after every Tween. There is a command inside Itween node where I can decide “go on with the flow data only after the move from/to node is complete?”

You can’t use delay nodes within functions as they rely on a tick to delay (functions have no concept of tick). You would need to do this within an event instead.

Hey all. I took a break from my game since 4.14 but now want to get back into it - 4.18 and I can’t compile iTween anymore on either Mac or Windows - far too many errors now.

Can anyone get it working or does more work need doing on the source code?

iTween is critical to my development!

Hello stansdad, I have a 4.18 build of the plugin and it works fine (even with a warning messages) for shipping builds. If is ok, I can send it to you. For 4.19 through, I think there will be need for a proper changes in the code of the plugin.