add character to clientstate and add sprint system
This commit is contained in:
parent
d5b77a9044
commit
d83ddf4e53
3 changed files with 41 additions and 2 deletions
34
src/ReplicatedStorage/ecs/systems/client/sprint.ts
Normal file
34
src/ReplicatedStorage/ecs/systems/client/sprint.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
import { World } from "@rbxts/matter"
|
||||
import { match } from "@rbxts/variant"
|
||||
import { clientState } from "ReplicatedStorage/ecs/state"
|
||||
|
||||
function sprint(_: World, client: clientState): void {
|
||||
if (client.lastProcessedCommand !== undefined) {
|
||||
match(client.lastProcessedCommand, {
|
||||
KeyDown: ({ key }) => {
|
||||
if (key === Enum.KeyCode.LeftControl) {
|
||||
client.isRunning = true
|
||||
}
|
||||
},
|
||||
KeyUp: ({ key }) => {
|
||||
if (key === Enum.KeyCode.LeftControl) {
|
||||
client.isRunning = false
|
||||
}
|
||||
},
|
||||
default: () => {
|
||||
// do nothing
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (client.isRunning && client.character) {
|
||||
client.character.Humanoid.WalkSpeed = 24
|
||||
return
|
||||
}
|
||||
|
||||
if (client.character) {
|
||||
client.character.Humanoid.WalkSpeed = 16
|
||||
}
|
||||
}
|
||||
|
||||
export = sprint
|
Loading…
Add table
Add a link
Reference in a new issue