is input key down preoblem, please help me

hi there.
im very sorry for the noob question but i tried almost everything.

i have a state machine that plays normal idle run Blend space.
upon condition is key pressed is active the preform cam up is done then the condition is cam up is enabled.

i only managed to do it with is key down which require me to hold the key down.
i want it to be on a key press, like a flip flop.
key pressed both conditions are active, key pressed again both are false.

what im trying to achieve is normal idle run anim.
key is pressed a camera up anim is played then an idle(cam up)Running(Cam up) anim is played so the user will see a continuous animation.

thank you very very very much.

Hi MrQoZy.

Have you tried a Flip-Flop node? This works as a toggle in Unreal and should allow you to set the run up as you want it. There’s an example of how to set this up here (see the crouch controls for example).

Hope this helps. :slight_smile:

But how!
In the animation blue print I csnt figure out how use the flip flop to do what I want.
It’s easy to set that in the character Bp for example with an input pressed.
But in the even graph in the animation Bp I csnt do it.

There are multiple ways of doing everything of course, but I’ll describe what I would do for this.

The Animation Blueprint is used to pull variables from the Character and Player Controller to drive animation. I would not set up any controls or game logic in the ABP, I would set them in a custom Player Controller BP class. I would have the 1 (or whatever) key set up as an Input Action. Then my Player Controller class would handle receiving that input, passing through a Flip Flop node (something like this), and setting a bool variable (called isRunning or something similar) to true or false. Then in the ABP I’d get the Player Controller, cast to my specific Player Controller class and get the value of isRunning. Then I’d use a branch off that to set the isKeyPressed and isCamUp variables.

You could also do something very similar in the Character BP. It seems this is personal preference in many ways, but I prefer all controls to be in the Player Controller BP.

Let me know if this is still unclear? I’m at work now but could post an example set up when I get home later if it helps. :slight_smile:

Edit - I’ve just realised that, if you’re quite new to Unreal, you may not know how casting works? It’s pretty essential for even quite simple things in the editor, if you’re not confident with that then see here as a first reference. It did take me some time to fully understand how casting works and how important it is.

Hi dude.
I really appreciate your answer.
If you don’t mind could you show me how?
About casting, I have an initial thought about it and how it works.

Actually as a solution I tried to reference the boolean in the ABP inside of character Bp as Its easy to do a flip flop there with an input, for example left shift or f.
But I wasn’t able to for some reason.

I checked all your references.
Some I saw before in an effort to understand and solve this issue.

If you could set a small Bp to show me how would you do things I’ll be extremely appreciative.

Anyway. Thanks for taking the time to reply.
Cheers :slight_smile:

Ok I understand what you are saying in your last reply.
I can cast to character Bp inside of abp event graph.
But inside the state machine I should set a boolean to activate the BS or the action.
How would I reference this boolean there?
Because I csnt cast there.
All I can see is" can enter a transition"
I can only add a boolean.
Can I cast there?
I don’t know :confused:
Thanks.

Not quite sure what you’re trying to do but maybe the DoOnce node is what you’re looking for?

Simply put I want something like outlast.
The character have idle walk run animation with no camera (in my Bp I simplified it to idle run, I’ll add walk later)

And upon hitting a key the preform animation is played (the character raises the camera and look through it) then another blend space is activated(the other blend space has the camera risen in the idle and run animation)

So like I said I’m trying to achieve an idle run animation, then key press character raises the camera then idle or run with it risen.

I hope I was clear.
Thank you for taking the effort to answer :slight_smile:

Hey MrQoZy. OK, I think I understand what you need. You’re right that you need a bool in the ABP to enable the CanEnterTransition.

Do something like this in the CharacterBP, where ‘Sprint’ is a custom event and isSprinting is a bool variable set up in the CharacterBP:

Then in the ABP:

Bad screenshot, sorry. :smiley: But off the branch at the end you’ll want to set your isKeyPressed variable (I’d recommend renaming that by the way to isSprintPressed) to true or false. Then that bool is set each time you press key associated with the Sprint custom event and you can use that in the CanEnterTransition.

This isn’t the only way to do it I’m sure, but it should work for you. Hope this helps. :slight_smile:

Incidentally I think you can use a Cast in the State Machine, but as far as I know it would have to be a pure cast and that has some potential issues. In relation to bools also be aware that there are other ways you can work out a true / false, like using < or > (setting a sprint to > 400 or something similar is quite common), and you can use AND or NOT statements if helpful, so you could for instance check if a button is pressed down AND if a character is moving at a certain speed.

hi. sorry for the late reply im back home. ill try it when i get back to my flat.

thank you soo much.
i really appreciate it

it worked :smiley:
thank you so much.
thank to this now i have a deeper understanding of ABP and BP in general.
thanks a lot

Excellent, glad it’s worked for you. :slight_smile: