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"

Start Animation gets Interrupted

I press WASD to play a certain start moving animation

If I remove WASD during the length of time which it takes for the start animation to complete it will blend back to idle But if I then press WASD during that same amount of time (i.e. before the start animation has time to complete its cycle, even if I have just blended back to idle) it will continue where it left off and play the rest of the start animation.

How can I make it do this:

if WASD has been pressed it will play the start animation from start to finish, without interruption?

Meaning you can mash WASD however you like but until you have blended into locomotion or until the start animation has completed itself and you blend back to idle, nothing will happen when mashing WASD buttons?

Please help!

This is all inside my AnimBP

Product Version: UE 4.11
Tags:
more ▼

asked Sep 08 '16 at 11:34 PM in Blueprint Scripting

avatar image

gogogad
8 5 12 17

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

1 answer: sort voted first

I assume you're using an animation state machine from within your AnimBP.

What you can do is when WASD is pressed, leave your Idle state and enter a state that plays your Start animation. The transition out of that Start state tests for the completion of the Start animation (via the TimeRemaining node). When that happens, it'll transition to your Locomotion state. The transition out of your Locomotion state is the absense of WASD, which takes it back to the Idle state.

more ▼

answered Sep 09 '16 at 01:24 AM

avatar image

sranck
301 6 6 18

avatar image gogogad Sep 09 '16 at 01:28 AM

With time remaining node I experience this problem:

If I release WASD during the start animation it will go back to idle...but if I press WASD again during the time it would have been playing it will blend back into that time during the animation rather than play again.

How can I force my start animation to finish playing once it starts?

Then kind of the same thing for my stop animation but it gets the value wrong. When I remove all WASD keys it will not play the correct animation because it won't log that W has been hit or SD has been hit...it just records 0 and therefore the stop animation won't play correctly. It just plays the 0,0 position in the blendspace.

avatar image sranck Sep 09 '16 at 01:33 AM

Would you be able to post screenshots of your state machine, the inside of your transition nodes, the inside of your state nodes, and the transition times for your transition nodes?

Or post your project, if that's possible.

avatar image gogogad Sep 09 '16 at 01:33 AM

I want to be able to mash WASD during the start or stop animation phase and have no interruption or change in animation. I would like to force the player to sit until the animation is done, and if they are not holding WASD during that time then it will either blend to stop (from start) or go to idle (from stop)...but if going from a start to idle how will it tell which stop to play if the player doesn't keep holding WASD? It has to log the value whether the player makes it to locomotion or not...so that it can play the correct stop animation which has the same scheme as locomotion (forward, right on a scale from -1 to 1)

avatar image sranck Sep 09 '16 at 01:37 AM

This is absolutely possible. It would be helpful to get screen grabs and/or your project first to see what you're currently doing.

Jumping ahead of myself, one thought is that you could create an animation notify event that gets fired when the Locomotion state is fully blended in. Then, in your anim event graph, you'd catch that event and only then would you allow your WASD bool flag to be reset.

But there may be a simpler solution - just need to see what you're doing first.

avatar image gogogad Sep 09 '16 at 01:42 AM

I will upload a video in just a few seconds...

I use root motion so I don't set speed at all...WASD drives the animation thru a blendspace

W is 1 S is -1 A is -1 D is 1

I clamp it if I am crouching, walking or jogging, or running

so in theory I should be able to press some combo of buttons and it outputs forward and right values to -1 or 1 (which might be clamped depending on if I toggle run or flip flop between walk or jog...or if I toggle crouch)

start and stop take these same values to output the proper animations in those directions which are dictated by the above -1 to 1 values for WASD.

avatar image gogogad Sep 09 '16 at 01:43 AM

My movement components are different too since I just set forward to forward var and right to right var...no need for addMovementComponent All this just outputs it as -1 or 1 and I will clamp it to differentiate between crouches and stuff inside the actual blendspace which can hold a lot if I add more than just 4 slices on the graph

avatar image gogogad Sep 09 '16 at 01:47 AM
avatar image sranck Sep 09 '16 at 02:13 AM

The low-res video is a little hard to see, but here's what it looks like is going on with the Start transition. In the Start to Locomotion transition, you're ANDing TimeRemaining with the control logic. Which means that if both MoveRight and MoveForward are 0 while you're playing the Start animation, Can Enter Transition will always be False, and so the transition will never leave. What's going to happen then is that your Start animation will complete and freeze at the end (or worst, will restart if you've accidentally set your Start animation to loop) until you've pressed WASD.

Try doing this:

alt text

Also, make sure your Start BlendSpace is set to not loop. This way, the transition will leave when the Start animation has (nearly) completed. If you tap WASD, the Start animation will play all the way through, and then you'll transition to your Locomotion state.

animtransition.jpg (86.5 kB)
avatar image gogogad Sep 09 '16 at 02:16 AM

I have no problem getting to locomotion, that is where the time remaining node is.

The problem is going from idle to start...the start animation can be interrupted.

My start blendspace is not set to loop.

There should be 720 on the video right now.

avatar image gogogad Sep 09 '16 at 02:18 AM

This is just saying if WS or AD are not 0 (i.e. one of the buttons has a value) AND the start animation time remaining is < 0.1 then you can move to locomotion.

i.e. you hold WASD and the start animation will finish playing up until 0.1 then move onto locomotion

avatar image sranck Sep 09 '16 at 03:32 AM

I'm assuming that MoveForward and MoveRight are "hard wired" to the WASD keys, so that they reflect the current state of the keys and you're not caching them, etc.

Ok, so here's what I'm saying. Let's say that you're in the Idle state. You tap W so that MoveForward is 1, and the transition from Idle to Start begins. The Start BlendSpace starts to play. While still in the Starts state, you immediately release W so that MoveForward is now 0. MoveRight is also 0. Ok, so now both MoveForward and MoveRight are 0 while you're inside the Starts state. So both inputs into the OR node are False, which makes the output of the OR node False. That gets fed into the top pin of the AND node. Anything ANDed with False returns False, and so the output of the AND node will always be False, regardless of TimeRemaining. And since the False output of the AND node is fed into CanEnterTransition, the transition is never entered and we stay in the Starts state forever, as long as you don't WASD again. So this is a problem.

Looking at your state machine, there is no way to go from Start back to Idle without having gone through Locomotion and then Stops. So what you're seeing, where it looks like it's going back to Idle, means that either you're going all the way through Locomotion and Stops and then back to Idle, or it just appears that you've gone back to Idle, but you really haven't, which could be explained if you're actually stuck in the Starts state longer than you meant to.

avatar image sranck Sep 09 '16 at 03:37 AM

Your Stops to Idles transition has a similar problem. Nix the inclusion of MoveRight and Moveforward, and just wire the output of TimeRemaining to CanEnterTransition.

avatar image gogogad Sep 09 '16 at 06:24 PM

I did as you said and I understand the true meaning behind and boolean...I have just used Time Remaining < 0.1

But I still have the problem where if I release WASD my start animation keeps playing in the background whereas I blend to idle. If I release WASD to go into stop animation it will always play the (0,0) stop animation rather than say (-1,0) or (1, 1) etc...because WASD will always result in 0 forward and 0 right as soon as I release the keys and go straight to stop animation. I need to drive the final WASD to the stop animation until it is finished.

My problem is I cannot mash WASD without the animations getting messed up.

avatar image gogogad Sep 09 '16 at 06:36 PM

To get upon your loop from idle to start to locomotion to stop back to idle...here is a video demonstrating me hitting WASD during the start and stop animation phase...you can kind of make out how the arrow AnimGraph setup shows how starts and stops can be interrupted but when they do where it takes the character through on the AnimGraph

Check it out: https://youtu.be/-I-PW47UGQQ It does need to be fixed somehow.

avatar image sranck Sep 09 '16 at 08:52 PM

The state machine looks better now. With that fixed, the next thing you'll need to do is to latch MoveForward and MoveRight so that if both keys are released, you don't update MoveForward and MoveRight to 0's until the Idle state is reached.

To do this, you'll need to add 2 anim notifies to your state machine. Put one on the "Start Transition Event" of the Idles to Starts transition, and call it ExitIdle. Put the other on the "End Transition Event" of the Stops to Idles transition, and call it ExitStops. Compile your anim BP (important, or else your notifies won't show up in the event graph yet).

In your event graph, right-click and type ExitIdle and create that node. Do the same for ExitStops. With these now in place, your event graph will know the instant you've started transitioning from Idles to Starts, and the instant you've finished transitioning from Stops to Idles. You can set a bool (Moving) to True when ExitIdle fires, and set it to False when ExitStops fires.

Now that you have that, in your event graph you can do these things:

If Moving is False, update MoveForward and MoveRight as usual.

If Moving is True, and any WASD key is pressed, update MoveForward and MoveRight as usual.

If Moving is True, and no WASD keys are pressed, don't modify either MoveForward nor MoveRight. Keep them at the values they previously were.

You may also need to add logic in the Idles to Starts transition that only allows the transition to be entered once the Stops to Idles transition has completed. You can do this by simply ANDing NOT-Moving into the rule in your Idles to Starts transition.

This may not handle your Turns and Jumps states yet, but trying to focus on the locomotion issue first. And not sure if I'm thinking through all of the logic, but this will hopefully at least get you pointed in the right direction.

avatar image gogogad Sep 09 '16 at 08:57 PM

This is where I add the notifies? I don't have to add any other settings other than a name correct? And which one do I select: start, end, interrupt

alt text

aaefaefa.png (9.9 kB)
avatar image sranck Sep 09 '16 at 09:00 PM

Yes, that's the place. And yes, just a name will enable it. I've described which slot to use in the post above.

avatar image gogogad Sep 11 '16 at 10:31 PM

I added Start and End Notifies and I set bool "Moving" for those Event Notifies.

Here is a video of what is going on: https://youtu.be/frhvs_Qu63Y

It is having problems because I can't hold two WASD buttons down at once, the start and stop won't play while I mash WASD. (Start because it won't continue the animation when I let go of WASD, Stop because it won't hold the WASD values to play the correct animation...it will always play 0,0 on the blendspace)

Any advice?

How do I actually store MoveForward and MoveRight values so that when I let go of them before the stop animation, the correct animation will play? The problem I see with this is it might record W or D if I am holding WD OR it might record WD for the stop value. It all depends on which buttons I release at the correct time.

avatar image gogogad Sep 13 '16 at 01:12 AM

Have you ever set this up before? Definitely a challenging setup. Setting last known run direction value so it checks your current run direction with that value to play the correct stop or something along these lines.

avatar image sranck Sep 13 '16 at 02:24 AM

The logic in your RootMotionCharacter_BP EventGraph doesn't look right. How about creating 2 new float variables called UserForward and UserRight. Simply set UserForward to the AxisValue of the InputAxis MoveForward node, and do the same for the UserRight. Ok, so now those 2 variables always reflect what the user is trying to do. After setting EITHER UserForward or UserRight, have the exit point of both of those Set nodes merge together into the same input of your Cast node. From there, implement branching logic that does this:

If Moving is False, set MoveForward=UserForward, and MoveRight=UserRight.

If Moving is True, and either UserForward!=0 or UserRight!=0, set MoveForward=UserForward, and MoveRight=UserRight.

If Moving is True, and both UserForward==0 and UserRight==0, don't modify either MoveForward nor MoveRight at all. No "Set" nodes for MoveForward and MoveRight in this condition.

avatar image sranck Sep 13 '16 at 02:28 AM

Actually, we'll still have a problem with the above. I think you're going to need to add a bool variable called HoldMovement, which defaults to False. When you detect that "Moving is True, and both UserForward==0 and UserRight==0", then you'd set HoldMovement to True. When HoldMovement is True, you will need to do the "don't modify either MoveForward nor MoveRight at all" thing regardless of the first two conditions. Then, when you've received the notification that you've returned to Idle, you'll need to set HoldMovement back to False.

avatar image gogogad Sep 15 '16 at 07:50 PM

Is there anyway to revert MoveForward and MoveRight back to 0 so that I can enter Idle state? After the stop animation plays my guy is forced back into start, then locomotion, then stop. I can hold WASD to stay in locomotion but I can't change directions when the guy has skipped his Idle phase!

https://youtu.be/aox0cAl30Tk

avatar image sranck Sep 15 '16 at 11:02 PM

Sorry, I've been really busy. From your latest video, it's looking really good.

The case where Stops is in progress and you then press WASD is a difficult case to handle. The easiest thing to do is to handle it the way we're doing now, so that if WASD is released we enter Stops and let it transition all the way through to Idle before Starts is allowed to be entered, even if WASD is pressed again while inside Stops.

But that may feel sluggish to the player. They may want to start running again the instant Stops is entered. If WASD is pressed while in Stops, it might be possible to transition from Stops into Starts, but begin the Start animation at a time other than 0, but this may prove difficult.

Another thing you could try is to add a transition from Stops to Locomotion, so that if WASD is pressed while inside Stops, you bail Stops and transition back to Locomotion. You may sometimes see some stuttering footwork, but maybe it'll look ok.

avatar image gogogad Sep 18 '16 at 09:46 PM

Do you know how I can speed up my turn-in-place animation when my yaw of the camera is too much?

I want my player to always face forward and not have the camera be able to look behind him if the player spins the camera around the character too much. With the animation speeding up the character can always look forward!

and add stand to crouch/crouch to stand animations?

I have a problem blending these to and from idle.

avatar image sranck Sep 19 '16 at 03:14 AM

Were you able to get things working? I've been slammed, so not much time available to help. Regarding speeding up the animation, do you know about the Play Rate pin available on the animation nodes in your anim BP? They're not exposed by default, but if you click on the node, you'll see a checkbox that says "(As pin) Play Rate". If you check it, the Play Rate pin will appear on your node. You can put this on your turn animations, and connect it to a float variable that defaults to 1.0. Then, in your event graph, you can increase the value for faster turns. Hope this helps.

(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