Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
PlayerStateWalk
ParentPlayerStateBaseFunctions
canWalk
DescriptionCheck if player is on the ground and he is not runningDefinition
canWalk()Return Values
bool | true | if player can swim |
46 | function PlayerStateWalk:canWalk() |
47 | local isRunning = (self.player.inputInformation.runAxis ~= 0.0) |
48 | |
49 | return self.player.baseInformation.isOnGround and not isRunning |
50 | end |
isAvailable
DescriptionCheck if state is availableDefinition
isAvailable()Return Values
bool | true | if player can swim |
28 | function PlayerStateWalk:isAvailable() |
29 | return self:canWalk() |
30 | end |
new
DescriptionCreating instance of state.Definition
new(table player, table stateMachine)Arguments
table | player | instance of player |
table | stateMachine | instance of the state machine manager |
table | instance | instance of object |
19 | function PlayerStateWalk.new(player, stateMachine) |
20 | local self = PlayerStateBase.new(player, stateMachine, PlayerStateWalk_mt) |
21 | |
22 | return self |
23 | end |
update
DescriptionUpdate method. Will deactivate if player is not moving anymore or if he starts running.Definition
update(float dt)Arguments
float | dt | delta time in ms |
35 | function PlayerStateWalk:update(dt) |
36 | local playerInputsCheck = (math.abs(self.player.inputInformation.moveForward) > 0.01) or (math.abs(self.player.inputInformation.moveRight) > 0.01) |
37 | |
38 | if not self:canWalk() or not playerInputsCheck then |
39 | self:deactivate() |
40 | end |
41 | end |