public override void SimulateController() { // IPlayerCommandInputInput input C'est comme ca on appel les Imput de Bolt //PlayerCommandInput.Create(); c'est comme ca On appel la classImput que j'ai crée dans l'inspector IPlayerCommandInputInput input = PlayerCommandInput.Create(); input.Forward = _forward; input.Backward = _backward; input.Right = _right; input.Left = _left; input.Yaw = _yaw; input.Pitch = _pitch; input.Jump = _jump; input.Fire = _fire; input.Scope = _aiming; input.Reload = _reload; //cette ligne est tres importante, elle permet de lister tout les imputs fait par le joeur entity.QueueInput(input); //Le joueur fait bouger le personnage dans lui sont monde vrai monde _playerMotor.ExecuteCommand(_forward, _backward, _left, _right, _jump, _yaw, _pitch); _playerWeapons.ExecuteCommand(_fire, _aiming, _reload, BoltNetwork.ServerFrame % 1024); }
//Le server et le client execute cette fonction public override void ExecuteCommand(Command command, bool resetState) { PlayerCommandInput cmd = (PlayerCommandInput)command; if (resetState) { _playerMotor.SetState(cmd.Result.Position, cmd.Result.Rotation); } else { PlayerMotor.State motorState = new PlayerMotor.State(); //Quand on est le server if (!entity.HasControl) { motorState = _playerMotor.ExecuteCommand( cmd.Input.Forward, cmd.Input.Backward, cmd.Input.Left, cmd.Input.Right, cmd.Input.Jump, cmd.Input.Yaw, cmd.Input.Pitch); _playerWeapons.ExecuteCommand(cmd.Input.Fire, cmd.Input.Scope, cmd.Input.Reload, cmd.ServerFrame % 1024); } cmd.Result.Position = motorState.position; cmd.Result.Rotation = motorState.rotation; } }