I use a timeline to rotate AI smoothly. However, I find that the first time I call the function which contains the timeline, AI can rotate smoothly. However, at the second time and third time, it can’t. It just instantaneously rotates. The following is my blueprint. The function is to make AI face to the first player character. What’s the problem? Thanks in advance!
You asked about timeline, so I will answer it first. To reuse the timeline simply call the event second time. To make it work in a simple way just use timeline’s exec “Play from Start” only. If you need more advanced functionality you need to add some conditions when timeline should play from start and when to set time and when to reverse, etc.
Now, actually to the part which should interest you:
NEVER add rotator values like that. Always use CombineRotators, to avoid Gimbal Lock:
This screen is from my blend camera blueprint. I call it every frame. If you want it to finish, the last “true” branch is way to go, change state or whatever. Just keep in mind error tolerance in the last condition (comparison of rotators), because of that the camera will never actually reach the target. That’s why, If you want it to STOP and not to tick anymore - add SetWorldRotation equal to the “RInterpTarget”.
When you are in this topic now, it’s worth a while testing these useful functions:
- Ease, Ease | Unreal Engine Documentation
- Different kinds of Interp
- Lerp
Here is a tutorial to Ease: