Creating brawl stars movement using "WASD"

Hello everybody,

As stated in the title, I’m trying to create brawl stars movement using WASD, But nothing is hitting my mind. And I’m not sure how it works. I’ve made it before using joystick. But I’m not sure how to do it using keyboard. After thinking a bit I feel like it works like this. You gotta press w to move forward, and when you press A, D or S, it’ll move that way. Please check out brawl stars and it’ll help you get the idea what type of movement I’m looking for. And is the way I said above the way to go about this movement. Examples and idea’s would be help me out a lot. Thanks!!

As someone who never played the game, it would help if you directly linked to a video showcasing the desired behaior instead of asking people to look for it themselves. From what i saw it looks like pretty normal smartphone joystick movement. Is there anything special about it, since you refered to it as brawl stars movement and not just joystick movement?

For now, yes. Pretty much just allow multiple inputs to allow more directions of movement. WSAD gives 4 directions, allowing two inputs (WD) allows 8. If you need any more than that you will have to calculate the desired direction over multiple frames to allow the user tapping one of the buttons to walk in one of the in-between directions (holding W and tapping D would allow for a north-north-east kind of direction).
To make it easier on you, there are input axis, but not sure if that’s what you want.

I might completely miss what you are looking for tho. In which case you might want to explain it more.

1 Like

Easiest way is to just move the player then rotate child graphics object to face the direction.

public float MoveSpeed = 3f;
public float RotationSpeed = 5f;
public CharacterController CharController;
public Transform GraphicsParent;

void Update()
{
    var h = Input.GetAxis("Horizontal"); // AD
    var v = Input.GetAxis("Vertical"); // WS

    // Move player
    var right = transform.right * h;
    var forward = transform.forward * v;
    var moveDir = right + forward;
    CharController.Move(moveDir * MoveSpeed * Time.deltaTime);

    // Rotate graphics
    if (moveDir.normalized.magnitude < 0.001f) return;
    var targetRot = Quaternion.LookRotation(moveDir, Vector3.up);
    GraphicsParent.rotation = Quaternion.Slerp(GraphicsParent.rotation, targetRot, RotationSpeed * Time.deltaTime); // Smooth
}

Or maybe try RotateTowards instead of Slerp.

1 Like

Hey, And yes that was very silly of me.

In my point of view, I find it a very different type of movement, none that I have seen though. But if you look at it, it’s the same as joystick movement :smile:

Yeah that’s what I thought. Clearing that up makes me even more confident!

Well, I guess if I ‘tap’ D, it’ll be a slight rotation in that angle. but yeah, you got what I’m tryna do

Nah you got it fine!! Thanks for your help :smile:

Hey Stardog, thanks for your reply. Thanks for that example, really helps me get the idea what I’m tryna do, and how to do. Will give it a go!

Hey Stardog. After trying that code, it works as I wanted it to so far, thanks a lot. Just one question is. When I click play, the position of the player is normal, but after clicked either W, A, S or D. It moves 1f up. I’ve legit got no clue why, got any idea?