x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Playing an animation from start once active ?

Is there a way to play an animation sequence from it's first frame and then set it to loop ?

I have a ledge climbing system where I blend from an idle animation to a moving animation. My problem is that the animation blend randomly in the timeline of the animation. I need to restart the animation from 0 once it's branch is active (when the blending from the idle to the moving animation start). Otherwise I get some nasty transitions because some poses in the animation are too far from the idle pose.

I was able to do it in UDK via a custom animation node, with something like this (unrealscript code) :

 //when this node become active, we restart the animation from 0
 //usefull for looping animation like ledge movements
 event OnBecomeRelevant() 
 {
     SetPosition(0.0f, false);
 }

Is this possible in UE4 ? Do I need a custom node too for that ?

I tried to use a State machine with a entry and then an idle loop but it didn't work. I could do a looping of a montage, but it's really not an elegant and optimized solution in my opinion. :'|

Product Version: Not Selected
Tags:
more ▼

asked Apr 09 '15 at 08:51 PM in Using UE4

avatar image

Froyok
260 21 26 37

avatar image staticvoidlol Apr 10 '15 at 08:41 AM

I've also been banging my head against UE4's animation system for some time now coming from UDK. The only proper way I've found to solve this is to

  • Create a Montage, and add both your single animation and looping animation to it.

  • Use this post as reference to set the looping animation correctly.

  • Create an AnimBlueprint with a single default node plugged into the final pose

  • Play the montage from code via SkeletalMeshComponent->GetAnimInstance()->Montage_Play(YourMontage);

  • You can also set the currently playing montage position via SkeletalMeshComponent->GetAnimInstance()->Montage_SetPosition(YourMontage, pos)

Really, the only way you have any control over animations from C++ is to use montages.

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

I'd recommend using states with climb and idle and make sure you have blending time for transition to be 0.f so not to be not confused with blending vs playing from start.

If you look at the state, it should show, where the animation starts when it gets activated. Inside of state, we reinitialize it whenever gets activated, so it should work.

Thanks,

--Lina,

more ▼

answered Apr 10 '15 at 08:39 PM

avatar image

nikolobin STAFF
695 14 12 33

avatar image Froyok Apr 11 '15 at 05:36 PM

With the help of Lina I was able to get it working via a State machine. :) Here is the setup :

When the player is climbing a ledge I will enter the state which for the moment looks like this : alt text

  • "Idle" is simply the idle animation when not moving along a ledge.

  • "LedgeLeftStart" is my moving animation to the left, but NOT looping.

  • "LedgeLeftLoop" is my moving animation to the left (the same one) but looping this time.

The condition to go from idle to LedgeLeftStart is just two boolean that I setup to know is the player is moving, and if he is moving to the left. If one of them is false, I got bakc to idle (hence the back and forth on the transitions o nthe graph).

The condition from LedgeLeftStart to LedgeLeftLoop is true if the animation from LedgeLeftStart has finished (and if the player is still moving), this means the first loop has been made and I can enter the loop state. The blending time between those two states is set to 0 as Lina mentioned. This way on the screen you have the feeling it's the same animation that is looping. This is the most important part of the graph of course.

The result looks like this : https://vine.co/v/eB3l7ZATUjw

state_ledge.jpg (82.3 kB)
(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question