S&box Wiki

Revision Difference

GameLoop#543965

<cat>Code.Game</cat>⤶ <title>GameLoop</title>⤶ ⤶ # Every Frame⤶ ⤶ ⤶ ## BuildInput⤶ ⤶ <upload src="1/8d91e85ff2d0ffa.png" size="6916" name="image.png" />⤶ ⤶ Every frame we build our input. This converts input from your mouse, keyboard and controller into a Command that can be sent to the server.⤶ ⤶ This is done by passing a `InputBuilder` class down to the gamemode - which then passes it to the current camera and pawn. These callbacks are generally used to do things like change mouse movement into view angles.⤶ ⤶ You can override all of this behaviour in your Game class by overriding BuildInput.⤶ ⤶ ⤶ ## BuildCamera⤶ ⤶ <upload src="1/8d91e8781053b7d.png" size="19199" name="image.png" />⤶ ⤶ Every frame we update the camera position. First we find the active `Camera` (Looking at Client.Camera first, if that was null we use Pawn.Camera) - which sets the position, rotation, fov etc.⤶ ⤶ After the camera is set up we call Game.PostCameraSetup. Thich is a useful place to set things up based on camera position, like the viewmodel positions.⤶ ⤶