How do I change paper2d animations from jumping to falling at the max height of the jump
I am having trouble with the logic for checking the apex of a jump, and then switching to the falling animation. Currently, I can get a jump animation to play at the start of a jump, but the player goes into a "falling" state even though he is still on the way up, which carries on until he lands on the ground again.
I am trying to play a looped animation for the entirety of the actual rise in jump velocity until the tip of the jump height... then on the way down, switch to another animation.
here is my blueprint as it stands
asked Apr 14 '15 at 06:35 AM in Blueprint Scripting
answered Apr 15 '15 at 04:56 PM
I have a way around this issue.
How I jump: I use the premade function within the game.
How I set the Boolean variables: For falling, I just use a premade function (again). It checks that, and it's all good. But for jumping, I get my velocity, break it up into the Z vector, and compare that with 0.
How I set the flipbooks: Pay attention to the order. If I didn't have my jumping system setup, then "Falling" would be checked as "True" if I'm moving up or down because of the function I used to set the falling variable. To combat this, I have it setup to check if I'm jumping first. If my Z velocity isn't positive, then it'll check out as "false", and it'll set me to the falling animation (if I'm moving in the Z axis). The system essentially overwrites the check for falling to check if I'm moving up first, and if I'm not, then I'm moving down and it'll set a falling animation.
I hope this helps.
PS: After review, I could probably redo the "Check if I'm falling" system by doing the same thing I did with jumping, but have the "greater than" float be replaced with a "lesser than" float (with the value still being 0). Although it's possible that there would be an issue where if my Z velocity hits 0 right before I start falling, then I'd hit the idle (or run, but I'm not sure) animation before it got set to the falling animation. But what I have works fine, so I'll probably just leave it as is until I need to do otherwise.
EDIT: Also, my animation state machine is created using an enumerator in conjunction with a function (no rhyme intended). So when you look at my "Animation State Machine" function, the "Animation State" setter that follows after the branches within it is an enumerator.
There is a solution that does not require the use of the Tick Event. The Character Movement component exposes a delegate in C++ that can be assigned to an event in Blueprint.
This only fires when the character enters the falling side of a jump or walks off a ledge. Use the OnLanded event to clear the isFalling variable.
Be sure to enable the Notify Apex in Character Movement Component.
The following code snippet can be cut and pasted directly into blueprint to create the Bind and Event nodes. Attach the Event Begin Play to the Bind Event.
answered Jun 03 '15 at 07:49 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here