Skip to content
This repository was archived by the owner on Jun 11, 2020. It is now read-only.

Fixes keyboard input canceling movement when opposing keys are pressed#165

Closed
spacek531 wants to merge 1 commit intoRoblox:masterfrom
spacek531:master
Closed

Fixes keyboard input canceling movement when opposing keys are pressed#165
spacek531 wants to merge 1 commit intoRoblox:masterfrom
spacek531:master

Conversation

@spacek531
Copy link
Copy Markdown

The current behavior of player scripts is that when opposing keys are held (such as W and S) the player stops moving. This is quite jarring and dissimilar to Roblox's controls before player scripts and dissimilar to most FPS games.

This update changes behavior by using leftValue, forwardValue, rightValue, and backwardValue as indicators that a key is pressed, and uses two different directional values (one for the X axis, and one for the Z axis) to determine walk direction. When a key is pressed, the direction value associated with the key gets forced into the key's direction. When the key is released, the code checks to see if the opposite key is being held to determine what the direction value should be.

Keyboard input will now favor the most recent key pressed when opposing
direction keys are pressed. This mimics behavior of many FPS games.
@osyrisrblx
Copy link
Copy Markdown

This is unexpected behavior. I don't think it should be implemented. For those who need it, they can implement it in their own games.

That's why we have PlayerScripts in the first place, isn't it?

@spacek531
Copy link
Copy Markdown
Author

@osyrisrblx it is not unexpected because, as I said in the description, Roblox did this before. The point of player scripts is to re-create what roblox did before, not change it.

This pull request does not re-create the exact behavior before player scripts: it does not favor W when both W and S are held, and it does not favor A when both A and D are held. Instead, it favors the most recently-pressed key: if S is being held, but the player needs to then change direction to W, the player will move forwards when W is first pressed, because it is the most recent. The same applies to A and D.

@Gskartwii
Copy link
Copy Markdown

This still is an issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants