Fixes keyboard input canceling movement when opposing keys are pressed#165
Fixes keyboard input canceling movement when opposing keys are pressed#165spacek531 wants to merge 1 commit intoRoblox:masterfrom spacek531:master
Conversation
Keyboard input will now favor the most recent key pressed when opposing direction keys are pressed. This mimics behavior of many FPS games.
|
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? |
|
@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. |
|
This still is an issue. |
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.