Animated Curtains

Ok, this is my first time setting up an animation in Unreal, but I have made some interesting progress. I am trying to create a simple window curtain that opens and closes when pressing the “C” key. So far, I have the curtain animation setup inside Unreal. But I have no idea how to get the C key to trigger the animation. I also would LOVE some feedback if this is the best approach. This is my workflow:

Create the Curtain inside 3D Max with a rod, bones, APex. Curtain in the closed position.
Imported the fbx and apex file into Unreal.
Opened the Curtain Skeleton inside Unreal and applied material. Verified everything came in correct.
Clicked the “Animation” tab at the top right and created a new animation file that animates the curtain sliding open. Works fine.
Dragged the Curtain into my scene.

At this point I am uncertain on how I can instruct my level blueprint to play the open animation on my curtain when the C key is pressed. Should I setup a State Machine?

Thanks!

EDIT: I noticed a bit late that you want to control it from your level blueprint, the solution would be to drag your curtain actor into level blueprint and work with it from there, like add input event and connect execution to it.
end of edit

There are many ways for almost everything.
One way would be to create an animation montage from your animation, then add “Play animation montage” node and point it to your montage, connect it to C key input event. Check for state and play the appropriate montage if needed.

Another way I could think of right away is to create two states in anim BP, one state called “Open” and another “Closed”. Add corresponding animation to each state and uncheck “Looped” checkbox on the bottom right. Then in the event graph of your anim BP create a bool variable, grab its value from the curtain actor. Add conditions to states to switch to the corresponding state when the variable is true or false. Set your variable on the actor in any way you prefer, for example connect it to C key input event.

Personally I would use the first way although the second one is not without it’s elegance I think. If you need more detailed explanation please say so and I am sure someone will elaborate, or I’ll do it when I wake up tomorrow.

VRL,

Thanks for replying. The montage option sounds promising. I’m researching how to setup a montage right now. I’ll let you know if I have any issues. Thanks for your feedback and suggestions!

Just right click on animation and find an option to create animation montage.

So I have an Animation Montage setup, but I’ve run back into the problem on how to get the events to trigger based off the C key. Should I set this C Key event on my FPS character? If so, how it cast to my Curtain Skeleton? I also created an “Animation Blueprint” with my Curtain to see if I could get it to work this way. Still haven’t figured out a connection with the C key.

edit – My Animation Montage has two events. “CurtainOpen” and “CurtainClose”.

First of all, sorry for misleading you before, it looks like only Character type can play animation montages. You still can play animations on any skeletal mesh though.
You could drag the curtain actor into your level blueprint and work from there like this:
a4eaba96156ea60b51072532efd6ba9723633fdf.jpeg

But this is a quick and dirty way, I don’t recommend it, although it could be viable, depending on your game and how everything is set up.

What I would do is perform a line trace from camera in character blueprint to detect if it is looking at a curtain and then cast from there and activate animation.ef7d11249361fa21eb75ed5e5463e1dca7f395bc.jpeg

This is just a basic setup, there are many ways to expand and improve it of course.

Hey thanks for this!
This looks like its in the right direction, but I have an issue. My BP_Curtain was created via Animation Blueprint. Do I need to setup any variables inside this blueprint? Because the Cast that I created in my Character’s Camera is setup exactly like your screenshot, but I am unable to create a “Target - Skeletal Mesh” node out of the “As BP Curtain” from the ->Cast To BP_Curtain". What am I missing to create this target connection?

Nevermind on my last post! Using the “Animation Blueprint” seems to have been the problem. I created a normal Blueprint and imported my curtain into here. The connection works fine now. But pressing the C key when I walk up to the current does nothing. Viewing the debug, the exec works all the way through but stops once it enters “Cast to BP_Curtain001”. The cast never continues to execute “Play Animation”. It is almost as if the name of the object doesn’t match the cast for some reason? Not sure whats going on. I am also walking within range of the curtain. The visible red trace line goes through it.

EDIT::

I think it has something to do with the LineTrace not detecting the curtain for some reason. I added a Print String, and when I press C on other objects, it tells me the name of the object, such as Wall_001 behind the curtain, but the curtain itself gives zero response to the trace. I may have put some collision change that I should not have. Looking into it.

Yes, it is probably a collision issue. Make sure the curtain has WorldStatic collision or change object type in the line trace to WorldDynamic or whatever it is. Or even change the trace to Trace for channel, select Visibility and set the curtain collision to block Visibility channel.

VRLtqq,

Yes! I had spoke to Minaosis in a private chat about this earlier, he said the same thing you mentioned. I have resolved this thanks to both of you. Thanks a lot!!