Download

Question about randomizing character movement.

I am fairly new to unreal engine so please bear with my ignorance. I am trying to make a character blueprint for a level where when you try to walk forward using W, you don’t actually walk forward but you have a chance to walk to the right, left or backwards. I’ve been stumped trying to figure out a way to get this to work correctly so any help would be appreciated. I’ve tried randomizing the world direction vector, but doing that prevents the character from doing any movement. I realize that logic may have been flawed however, because I’m not wanting it to be truly random, but pick from 1 of 4 directions. So how should I actually try to handle this issue?

In the add movement input node, you should change the input value from World Direction passing the GetControlRotation->GetForwardVector (for the forward/backward direction) or GetControlRotation->GetRightVector (for the side direction). If you randomize the vector to any value you will never know which direction the player will move and even more if the vector is not normalized.

I’m not sure the real direction that these result would leave but is something like this that you can use to randomize your 4 directions:

Forward Direction = GetControlRotation->GetForwardVector
Backward Direction = GetControlRotation->GetForwardVector * -1
Right Direction = GetControlRotation->GetRightVector
Left Direction = GetControlRotation->GetRightVector * -1

I believe I could point out a better solution if you show me your blueprints.

You could use a multigate like this: NOTE I realised I mixed up the ‘Set W_IsPressed’ bool. The tick should be after you press it, the untick after release.

Close Ups: