public override void SimulateController() { PollKeys(false); IPlayerInputCommandsInput input = PlayerInputCommands.Create(); input.MouseMovement = new Vector3(MouseX, MouseY); input.MovementInput = new Vector3(Player.MovementInput.Get().x, Player.MovementInput.Get().y); entity.QueueInput(input); }
public override void ExecuteCommand(Command command, bool resetState) { PlayerInputCommands cmd = (PlayerInputCommands)command; if (resetState) { // we got a correction from the server, reset (this only runs on the client) Player.movement.CorrectPosition(cmd.Result.Position); } else { if (entity.isOwner) { state.Pitch = cmd.Input.MouseMovement.y; } // apply movement (this runs on both server and client) Player.movement.MovePlayer(cmd.Input.MovementInput, cmd.Input.MouseMovement); // copy the motor state to the commands result (this gets sent back to the client) cmd.Result.Position = transform.position; } }