Trying to toggle walk speed of an AI while key is pressed

So ive only been with UE for a couple days now, so forgive me if this is something simple, but all im trying to do is alter an NPC’s max walk speed for the duration of a key being held (changes run speed to 1000 until you let go) and in my head, this should run no problem based on what ive read/watched but i cant find anyone trying to do the same thing as this. From my attempt to debug it, its not getting any input from the keyboard (Light is just a press of the F key which i call elsewhere and works fine), I also tried adding a event for the jsut F key rather then the custom input and still nothing. Any help would be awesome.

You need to enable input in the BP in order to be able to give input to the BP. Try this:

Is that not exactly what I have tho? Like right in the middle there?

Ah yes now I see it in the middle there…sorry…what values do you have set for the Run Speed and Walk Speed? Try this add a print string and the F key pressed and released and set the string to print pressed and then released…this will tell us if the pressed and released are being fired, they may not fire at all because the AI has it’s own controller as well and that most likely wont allow for to inputs from different controllers…

It may be better to set the key press in your character and then custom events in the NPC and when you press the key your characterBP calls the custom event to fire in the NPC.

I did try the print string before this and no messeges came up on the screen, currently 100 and 1000, just for testing purposes, and the default run speed of that NPC also at 100. If you think that would be better I can try it, care to offer a how do since I dont even know where to start with that…lol

Sure give me a minute to throw something together…opps forgot to actually post that…without getting into interfaces or anything too complicated this is a really basic way you could do this:

In the player BP:

And in the NPC BP:

83782-npccustomevents.png

This looks great, Ill give it ago in a little, thanks so much for all the help =] never would have thought of something like that on my own

you actually use CharacterMovement component and access the acceleration, also, from the same component you can set max speed

Play around with these values and I think you’ll get it done :slight_smile:

This worked perfectly! And gave me a better understanding on how the cast to’s work to use in the future, thanks so much!