Animation of simple things... like. a door..

Hi…

I´m looking for the way to animate a door opening and closing, not sure what to choose to make it. In Unity there is the legacy system animation where you simply select the object, create the animation file and setup the keyframes… but looks like in Unreal is a bit more complex… isn´t ? because I see in everywhere the skeleton word on any animation function , but I don´t want to animate skeleton made models… just simple models like a door…

i forgot to mention that I followed an official tutorial of Building Geometry and there it explains how to animate a glass door, but I don´t want to use Blueprints… just c++

What is the correct option?
Thanks.

The easiest way is to use BPs and add a timeline which rotates the door. If you want to do it in C++ it’s the same, just in code.

so, does that means I can´t do an animation using GUI tool and call it from code?.. for instance this is the way Unity uses to animate something:

First I make the animation using Animation Window, setting up the keyframes with a previously selected object, mark first frame, set positionZ to 100, mark the frame 25, set positionZ to 180… that is written in an .anim file called AnimationClip, then I drag and drop that file into the inspector panel of my object…

Then from code:




//Pre-made animationclip execution
Animation myObjectAnim = GetComponent<Animation>();
myObjectAnim.Play();


//Versus:


//Moving object through scripting:

Transform destinyPoint = GAmeObject.Find("destinyPoint").GetComponent<Transform>();

void Update () {
     Vector3.Lerp(transform.position, destinyPoint.position, 3f);
}



using an animation window editor es a lot easier and fast to do more complex animations, using the code is hard and slow and the problems comes up when you have a prefab using multi-parts Childs using different animations…

The timeline in BP is basically a GUI tool. But you can try the Actor Sequence plugin added in 4.15, it’s experimental though. Enable that and add an actor sequence component to your BP, then use the Sequencer UI to animate whatever you want to do.

thanks for your answer…

can i use BP and C++ together?.. you know… create the animation in timeline using BP and play from c++ ?

In my opinion the simplest way to achieve that is using a timeline, but instead of putting Start and End positions of the door, just create a float variable that goes from 0 to 1 in the amount of time that you want the door to open (1sec, 2secs, etc.), then use Lerp and use the value of the float as alpha, this will allow you even to select how much you want the door to open if you use variables and put them public in the editor.

I put a blueprint which will be more graphical to understand, but this is also achievable from C++

I guess you could but when you’ve made the timeline you’re 90% there anyway. Just use the solution posted above.