主なコンテンツ

〜主なコンテンツ〜

1. Unityで製作したゲームと製作Tips
  1. 三月精チャレンジ(東方Project二次創作)
    1. 作り方
  2. 英語学習2D(オリジナルスマホアプリ)
2. UE4
3. ゲームアプリ見学
4. Bitbucket & SourceTreeでの一連の流れ
  1. 前半
  2. 後半
5. Tips
  1. UnityのTips
  5. SQL文のTips
  6. Final IK
  7. GearVR+Unity

2022年12月4日日曜日

23. Tracking Incoming Players

 いらっしゃいませ。


このレクチャーでは、ゲームに入ってくるプレーヤーを追跡できるように、ゲーム モードを作成します。


そうすれば、参加したプレーヤーの数を追跡する実行中のプレーヤー数を出力できます。


後で、このプレイヤー数を使用して、ロビーから実際の試合に移行する必要があるかどうかを判断できます。


これを行う方法は、ゲームの状態を使用することです。


マルチプレイヤーに関して非常に重要な 2 つのクラスは、ゲーム モードとゲーム ステートです。


ゲームモードは、ゲームのすべてのルールを維持するために存在します。


これには、プレイヤーを新しいレベルに移動するタイミングやスポーン場所の選択方法など、ゲームに応じてさまざまなことが含まれます。


ゲーム モードには、プレイヤーがいつゲームに参加したか、いつゲームから離れたかを追跡するのに役立つ、いくつかの継承された関数があります。


ポスト ログインは、プレイヤーがゲームに参加し、そのプレイヤー コントローラーにアクセスできるたびに呼び出される、継承された仮想関数です。


ログアウト関数は、プレイヤーがゲームを離れたときに呼び出され、再びコントローラーとこの関数にもアクセスできます。


GAME STATE は、ゲームに関する状態情報を保持するように設計されています。


クライアントは GAME STATE にアクセスして、この情報を取得できます。


これは、スコアや勝利数などの特定のプレイヤーに関する状態情報ではなく、ゲームの状態情報を保持するように設計されたクラスです。


Game State にはプレイヤーの状態の配列が含まれており、プレイヤーの状態クラスは、スコア カウントなどのプレイヤー固有の情報を保持するように設計されています。


ゲームモードはゲームの状態にアクセスできるため、この配列のプレーヤーの状態を取得し、この配列のサイズをチェックすることでゲームに参加しているプレーヤーの数を確認できます。


これが私たちがやろうとしていることです。


まず、プロジェクトのゲーム モードを作成しましょう。


Welcome.


In this lecture, we're going to create a game mode so that we can track incoming players to our game.


That way, we can print a running player count that keeps track of the number of players who have joined.


Later, we can use this player count to determine whether we should transition from the lobby into an actual match.


Now the way we're going to do this is through the game state.


Two very important classes when it comes to multiplayer are the game mode and the game state.


The game mode exists to keep all the rules for the game.


This can involve any number of things depending on your game, including when to move players to new levels and how to select spawn locations.


The game mode has a couple of inherited functions that are useful for tracking when a player enters or leaves the game.


Post login is an inherited virtual function that gets called whenever a player joins the game and we have access to that player controller.


The logout function is called When a player leaves the game and again we have access to the controller and this function as well.


the GAME STATE is more designed to hold state information about the game.


Clients can access the GAME STATE and get this information.


Now this is a class designed to hold a game state information, not state information about specific players like score and number of victories, things like that.


The Game State contains an array of player states and the player state class is more designed to hold player specific information like score counts.


The game mode has access to the game state so it can get this array of player states and see how many players are in the game by checking the size of this array.


So this is what we're going to do.


So first, let's create a game mode for our project.

(中略)

ここに gameModeBase.h があり、post log in を検索できます。post log in 関数を説明する多くのコメントと共にここで見つけることができます。


「ゲームによってオーバーライド可能なplayerControllerを作成することにより、新しいプレーヤーにログインするために呼び出されます」と書かれています。


そのため、ポスト ログインが呼び出されるまでに、プレーヤー コントローラーがプレーヤー用に作成されます。ここには、「これは、playerController でレプリケートされた関数を安全に呼び出すことができる最初の場所です」と書かれています。


今後のビデオでレプリケーションについて詳しく説明しますが、この時点で playerController に安全にアクセスできることがわかっています。


私はそれを閉じるつもりです。


したがって、これらの関数本体を作成できます。


ここに関数本体があります。


次に、これらの関数のスーパー バージョンを呼び出します。


supe::postLogin と言って、その newPlayer を渡します。


ログアウトするには、super::logout を呼び出して、終了しているプレーヤーを渡します。


ここから投稿してログインすると、ゲームの状態にアクセスできます。


そして、これは単にゲーム状態と呼ばれる変数としてゲーム モードに存在します。


これで、ゲーム ステートにプレーヤー配列が追加されました。


それで、それにアクセスします。


そしてここ。


これにカーソルを合わせると、ゲームの状態が実際に TObjectPointer と呼ばれるものにラップされていることがわかります。


そしてこれは、Unreal Engine 5 がますます使用する方向に進んでいるものです。


生のポインター型を使用するだけでなく、型に使用できる安全なラッパーです。


ゲームの状態に関するものにアクセスできますが、これは TObjectPointer であるため、TObjectPointer が格納しているもの、つまりゲームの状態そのものを取得する必要があります。


したがって、ゲーム ステートを使用してこれを行うことができ、TObjectPointer ラッパー関数 get を呼び出すと、実際には gameStateBase ポインタが返されます。


そこから矢印演算子を使用して、プレーヤー配列などにアクセスできます。


現在、playerArray は TArray であり、配列内のオブジェクトの数を返すこの num 関数があります。


したがって、必要に応じて、これを numberOfPlayers というローカルの int32 に格納できます。


これで、ゲームに参加しているプレイヤーの数がわかりました。


これを画面に出力したいと思います。


したがって、プレイヤーが参加するたびに、この数のプレイヤーを表示できます。


したがって、IF GEngine と言ってから、GEngine->AddOnScreenDebugMessage を呼び出すことができます。


プレーヤーの数を表示するときは、この関数に 1 のキーを使用したいと思います。


そのため、同じキーを持つ新しいオンスクリーン デバッグ メッセージを追加するたびに 1 つのキーを使用することで、古いキーが置き換えられるため、複数のメッセージが画面にスパム送信されることはありません。


そのため、メッセージを画面に表示したまま、たとえば 60 秒間表示したいと思います。


ただし、プレーヤーが参加するたびに、新しいメッセージが追加されます。


したがって、この 60 秒が再開されます。


FColor::yellow を使用します。


メッセージには FString::Printf を使用します。


したがって、テキスト文字列については、"Players in game %d" とします。%d を使用するのは、整数であるプレーヤー数の値を使用するためです。


それで、そこに何人かのプレーヤーを渡します。


ここで、誰かが参加したことを示すメッセージも表示したいと思います。


そこで、別のオンスクリーン デバッグ メッセージを追加しますが、今回はキーに -1 を使用します。


そうすれば、誰かが参加したときに画面に大量のメッセージがスパム送信されるのを見ることができます.


色はシアンを使ってみましょう。


このために、誰がゲームに参加したかを示したいと思います。


だから私は %s を使って「ゲームに参加しました」と言います。


では、この文字列を何でフォーマットするのでしょうか?


そこで、プレイヤーの名前を出力したいと思います。プレイヤーの状態から取得できます。


また、プレーヤーの状態にはコントローラーからアクセスできます。


これで、この playerController、newPlayer ができました。


先に進み、APlayerController を右クリックして [定義に移動] を選択します。


ここで playerController を見ると、playerController が AController を継承していることがわかります。


それに飛び乗りましょう。


そして、ここAcontrollerで。


getPlayerState を検索できます。


これにはテンプレート パラメーターがあることがわかりますので、指定する必要があります。


ゲームモードに戻って、プレイヤーの状態にアクセスしましょう。


まず、ここで newPlayer を使用します。


そこで、newPlayer->getPlayerState と言って、APlayerState を指定します。


これで、これをローカル変数に格納できます。


したがって、APlayerState* playerState と言って、これと等しくなるように設定します。


そして、プレイヤーの状態が有効であることを確認できます。


プレイヤーの状態から、その名前を取得できます。


したがって、playerState を取得して getPlayerName を呼び出すと、名前が取得されます。


そのタイプを使用しようとしているので、playerState インクルードが必要です。


ここにAPlayerStateのドキュメントがあり、インクルードはgameFrameworkにあります。


それをコピーして、インクルードを一番上に貼り付けます。


これで、プレイヤーの状態が取得され、プレイヤー名にアクセスしています。


これで十分な文字列が返されるので、これとプレイヤー名と呼ばれるローカル文字列を保存できます。

Here's gameModeBase.h and we can search for post log in and we'll find it here along with lots of comments that explain the post log in function.


It says "called to login new players by creating a playerController overrideable by the game".


So by the time post login has been called a player controller has been created for the player. and it says right here that "this is the first place it is safe to call replicated functions on the playerController".


Now we'll get more into replication in future videos, but we know that it's safe to access the playerController at this point.


I'm going to close that.


So we can create function bodies for these.


So here we have our function bodies.


Now we're going to want to call the super versions of these functions.


So we're going to say supe::postLogin and pass in that newPlayer.


And for log out, we'll call super::logout, passing in that exiting player.


Now from here in post, log in, we can access the game state.


And this exists on the game mode as a variable, simply called game state.


Now the game state has a player array.


So we're going to access that.


And here.


Now, if we hover over this, we see that game state is actually wrapped in something called a TObjectPointer.


And this is something that Unreal Engine five is going to move towards using more and more.


It's a safe wrapper that can be used for types rather than just using raw pointer types.


We can access things on the game state, but because this is a TObjectPointer, we have to get the thing that the TObjectPointer is storing and that's the game state itself.


So we can do that using the game state and calling the TObjectPointer wrapper function get this will actually return the gameStateBase pointer.


And from there we can use the arrow operator to access things like the player array.


Now the playerArray being a TArray, it has this num function which will return the number of objects in the array.


So if we wanted to, we could store this in a local int32 called numberOfPlayers.


So now we know how many players are in the game.


Now I'd like to print this to the screen.


So each time a player joins, we can display this number of players.


So we can say IF GEngine and then call GEngine->AddOnScreenDebugMessage.


Now when we display the number of players, I'd like to use the key of 1 for this function.


So by using the key of one each time we add a new on screen debug message with the same key will replace the old one so we won't get multiple messages spamming the screen.


So I'd like the message to remain on the screen for, say, 60 seconds.


But each time a player joins will be adding a new message.


So this 60 seconds will restart.


I'm going to use FColor::yellow.


And for the message we'll use FString::Printf.


So for the text string, we're going to say "Players in game %d" and we're using %d because we're going to use the value of number of players, which is an integer.


So we'll pass a number of players in there.


Now, I'd also like to display a message indicating that someone has joined.


So I'm going to add another on screen debug message, but this time I'm going to use -1 for the key.


And that way we can see lots of messages spamming the screen when someone has joined.


Let's use Cyan for the color.


And for this I'd like to show who joined the game.


So I'm going to use %s and say "has joined the game".


So what are we going to format this string with?


So I'd like to print the name of the player and we can get that through the player's state.


And the player's state is accessible through the controller.


Now we have this playerController here, newPlayer.


Let's go ahead and right click on APlayerController and select go to definition.


Now here in playerController, we see that playerController inherits from AController.


Let's jump over to that.


And here in Acontroller.


We can search for getPlayerState.


And we see that this has a template parameter, so we have to specify.


So back here in our game mode, let's access that player state.


So first, we're going to take our newPlayer here.


So we're going to say newPlayer->getPlayerState and we're going to specify APlayerState.


Now we can store this in a local variable.


So we're going to say APlayerState* playerState and set that equal to this.


And then we can check to make sure player state is valid.


And from the player's state, we can get that name.


So if we take the playerState and call getPlayerName, then we'll get the name.


we need the playerState include, since we're attempting to use that type.


So here's the APlayerState documentation and the include is here it's in gameFramework.


So we'll copy that and paste the include here at the top.


And now we have the players state and we're accessing the player name.


Now this returns enough string so we can store this and a local string called player name.

これで、この呼び出しを使用して画面上のデバッグ メッセージを追加し、Ctrl + X でそれを切り取ることができます。


ここに貼り付けて、プレイヤー名を渡してこの文字列をフォーマットします。


わかった。


誰かがゲームに参加したことを表示していますが、このコードをすべてコピーしてここに来て、ログアウトしてここに貼り付けることができます。


現在、newPlayer の代わりに、この既存のプレーヤーを使用しています。


これをそのまま貼り付けて、文字列を変更して、このプレイヤーがゲームを終了したことを伝えます。したがって、これを exited に変更します。


そのため、プレイヤーがゲームを離れたときにメッセージを更新する必要があります。


そのため、このオンスクリーン デバッグ メッセージをここにコピーします。ここに貼り付けて、プレイヤーがゲームを離れたときにログアウトします。


だから私はここに彼らの右を貼り付けるつもりです、そして我々はプレーヤーの数が必要になります.


ですから、それも取得します。


これは、この行で行われ、プレイヤーを gameState から遠ざけます。


それをここに貼り付けて、誰かがゲームを離れたときにメッセージを置き換えます。


ここのプレイヤー数はまだ更新されていません。


ログアウト関数を呼び出すときに、ここにちょっとしたハックを配置して、この値から 1 を引くと、実際に正しい数値が表示されます。


これはハックです。


これは、パッケージ化されたプロジェクトで使用するものではありません。


これは、テスト中に正しい数値を確認できるようにするためです。


これで、プレイヤーの出入りを追跡するゲーム モードができました。


そしてもちろん、私が見落としていたもの。


これは確かに F 文字列ですが、C スタイルの文字列が必要なため、ここではアスタリスクを使用する必要があります。


そのため、こことここでログアウトする必要があります。


それで、それは私の代わりに見落としでした。


わかった。


では、これをテストしたいと思います。


その前に、ここで設定したい別のセッション設定があります。


ここの multiplayerSessionSubsystem.cpp では、createSession 関数にいます。 lastSessionSettings に別の設定を追加します。その設定は buildUniqueID になります。これを 1 などの値に設定します。


ここで buildUniqueID にカーソルを合わせると、検索中に異なるビルドが互いに見えないようにするために使用されていることがわかります。


これを 1 に設定すると、複数のユーザーが独自のビルドとホスティングを起動できます。


そうすれば、有効なゲーム セッションを検索すると、それらの他のセッションが表示され、それらに参加できるようになります。


そうしないと、それらを見ることができず、最初にホストされたものに参加しようとすることになります.


そのゲームに開いている接続がない場合は、参加できません。


ここで、必要な数のプレーヤーを持てるようにする必要もあります。つまり、構成ファイルの 1 つに、追加する必要がある別の設定があることを意味します。


config フォルダーを開くと、defaultEngine.ini が既に編集されていることがわかりますが、defaultGame.ini ファイルにも設定する必要があります。


その設定には別のセクションを含める必要があり、それは Script/Engine.GameSession になります。


このセクションでは、maxPlayers 設定を使用し、それをゲームで必要なプレイヤー数に設定します。


これは、オープンな公開接続の数とは異なります。


これは特定のセッションの接続数を指定していますが、この設定はゲーム プロジェクトのプレイヤーの最大数を指定しています。


これを 100 に設定すると、ゲームの最大プレイヤー数が 100 に設定されます。


これをパッケージ化してテストする前に、ここにいくつかのデバッグ メッセージを出力していますが、他のデバッグ メッセージ、つまり Steam に接続しているメッセージはあまり必要ではないように感じます。


そこで、これをただ削除するのではなく、メニュー システム キャラクターに移動します。そこに残したいと思います。


それでは、デバッグ メッセージをコメント アウトしてみましょう。


これは文字コンストラクターにあるため、これをコンパイルできます。


エディターに戻ると、メニューのみを使用するため、1 キーと 2 キーにマップされたこれらのブループリントの呼び出し可能な関数はもう必要ありません。


それでは、先に進んでそれを削除し、コンパイルして保存して閉じましょう。


わかった。


これで、ゲーム モード クラスが作成されました。


これをもとに設計図を作っていきましょう。


さて、これはデモンストレーション プロジェクトなので、ブループリントの thirdPersonCPP に貼り付けます。[ブループリント クラスの選択] を右クリックし、[すべてのクラス] の下に表示されます。


ロビー ゲーム モードを検索して選択し、選択をクリックします。これを BP_LobbyGameMode と呼びます。このロビー ゲーム モードを開き、DefaultPawnClass が DefaultPawn ではなく thirdPersonCharacter に設定されていることを確認します。 .


そうすれば、ロビーに移動しても走り回ることができます。


というわけで、コンパイルして保存します。


次に、ロビー レベルのゲーム モードを設定する必要があります。


では、マップを開いてロビーを開きます。

Now we can take this call to add on screen debug message and Ctrl + X to cut it.


And we can paste it in here and we can pass and player name to format this string here.


Okay.


So we're now showing when someone has joined the game, but we can copy all of this code and come down here and to log out and paste it all in here.


Now, instead of newPlayer, we're using this exiting player.


So we're going to paste that in right there and we can change our string to say that this player has exited the game. So, we'll change this to say exited.


So we need to update the message when the player leaves the game.


So we're going to copy this on screen debug message here. and we'll paste it down here and log out when a player leaves the game.


So I'm going to paste their right here and we'll need the number of players.


So we'll get that as well.


That's going to be with this line here, getting the player away from the gameState.


So we'll paste that here and that way will be replacing the message when someone leaves the game.


The number of players here is not updated just yet.


When calling the logout function, we can place a little hack here and subtract one from this value so that we're actually printing the correct number.


Now this is a hack.


This is not something we would use in a packaged project.


This is just so that we can see the correct number while testing.


Okay, so now we have a game mode that tracks when the players enter and leave.


And of course, something that I overlooked.


This is indeed an F string, but we need to use the asterisk here because we need a C style string.


So we're going to have to do that here and down here in log out.


So that was an oversight on my behalf.


Okay.


Now we'd like to test this out.


And before we do so, there's another session setting that I'd like to set here.


So here in multiplayerSessionSubsystem.cpp, I'm in the createSession function. and I'm going to add another setting to lastSessionSettings. and that setting is going to be buildUniqueID I'm going to set this to a value such as one.


Now if we hover over buildUniqueID, we see that it says use to keep different builds from seeing each other during searches.


Now, if we set this to one, then we can have multiple users launching their own builds and hosting.


And that way, when we search for valid game sessions, we'll see those other sessions and be able to join them.


Otherwise we wouldn't be able to see them and we'd be trying to join the first one that was hosted.


And if that game doesn't have any open connections, then we won't be able to join it.


Now, we'd also like to make sure that we can have as many players as we want, and that means that there's another setting in one of the config files that we need to add.


If we open our config folder, we know that we've already edited the defaultEngine.ini, but there's also a setting we should put in the defaultGame.ini file as well.


And that setting is going to involve including another section and that's going to be Script/Engine.GameSession.


And in this section, we're going to use the maxPlayers setting and we're going to set that to the number of players we would like in our game.


And this is different than our number of open public connections.


This is specifying the number of connections for a particular session, whereas this setting is specifying the max number of players for our game project.


So I can set this to 100 and that will set our max number of players for the game to 100.


Now, before we go and package this up to test it, we're printing some debug messages here and I feel like we don't really need some of the other debug messages, namely the one where we're connecting to steam.


So I'm going to go into menu system character now rather than just delete this, I'd like to leave it there.


So let's go ahead and comment out the debug message.


This is in the character constructor so we can compile this.


And back here in the editor, we no longer need these blueprint callable functions mapped to the one and two keys since we're going to use the menu exclusively.


So let's go ahead and remove that and compile and save and close that.


Okay.


So we've created our game mode class.


Let's go ahead and make a blueprint based on this.


Now, since this is a demonstration project, I'm just going to stick it here in thirdPersonCPP in blueprints, right click Select Blueprint Class and under [all classes].


I'm going to search for lobby game mode and select that and click select and I'm going to call this BP_LobbyGameMode and I'm going to open this lobby game mode and just make sure that the DefaultPawnClass is set to not DefaultPawn but thirdPersonCharacter.


And that way when we travel to the lobby, we'll still be able to run around.


So I'm going to compile and save that.


Now we need to set the game mode for the lobby level.


So I'm going to go into maps and open lobby.

ここでは、worldSettings の gameModeOverride でロビー ゲーム モードを選択しますが、BP_LobbyGameMode を選択する必要があります。


これは、ロビー ゲーム モードである C++ クラスを選択すると、これらがすべてグレー表示され、デフォルトのクラスを変更できないためです。


したがって、これを BP_LobbyGameMode に変更すると、デフォルトのポーン クラスが thirdPersonCharacter であることがわかります。


デフォルトのポーンがあった場合、デフォルトのクラスにはその動きが複製されていないため、お互いが動き回るのを見ることができないため、非常に重要です。


つまり、移動時に移動情報はサーバーに送信されませんが、デフォルトで thirdPersonCharacter が複製されます。


そのため、同じレベルで一緒に走ったりジャンプしたりできます。


これで、ロビー レベルのゲーム モードが構成されました。


thirdPerson のサンプル マップに戻ることができます。


わかった。


では、あなたの挑戦のために、プロジェクトをパッケージ化して圧縮し、Google ドライブに貼り付けて、discord に参加し、あなたのゲームをプレイテストしてくれる他の学生を見つけてください。


複数の学生を見つけることができるかどうかを確認してください。


ここには制限がないことを忘れないでください。


その menuSetup、ブループリント、呼び出し可能関数、およびレベル ブループリントでパブリック接続の数を設定する必要があるだけです。


これをテストし、セッションをホストして、プレーヤーの数を追跡し、名前を確認して走り回れるかどうかを確認してください。


これは大きなマイルストーンであり、他のアンリアル エンジン プロジェクトに追加できるシステムを手に入れたので、少し楽しんで自分自身を祝福してください。


ビデオを一時停止し、他の生徒を見つけて、メニュー システムのプレイテストを行います。


これで、これをテストする準備が整いました。複数のプレイヤーでテストしたいと思います。


そのため、プラットフォーム、Windows パッケージ プロジェクトに移動してゲームをパッケージ化し、最後にビルドした現在のビルドを削除して、フォルダーを選択します。


これをテストするために、YouTube でライブ セッションを開催し、ゲームをパッケージ化して Google ドライブに配置し、生徒と私の不協和音に提供しました。


そして、ライブストリームに何人かの学生に参加してもらいました。


ここでお見せするのは、そのライブ ストリームの映像です。


そして、かなりの数のプレイヤーが参加して走り回り、私と一緒にこれをテストしました。


これがあなたが見ているものです。


そこで、このライブ ストリームからいくつかのクリップをお見せします。


また、ライブ ストリーム ビデオ全体を視聴したい場合は、説明にあるリンクのいずれかをたどって、ライブ ストリーム全体を視聴できます。


そして、ここに数人の人が参加しています。


ようこそ、皆さん。


このゲーム ビルドでどれだけ取得できるか見てみましょう。左上にあなたの名前が表示されます。


興味がある方のために説明すると、左上のこれらのメッセージは単に画面上のデバッグ メッセージであり、ゲーム モードから出力されています。


ゲーム モードは実際にはサーバー上のホスティング マシンにしか存在しないため、請求書にこれらのメッセージが表示されないのはそのためです。


そして、私はこのゲームのリッスン サーバーです。


基本的に、ゲーム モードはデバッグ メッセージを出力し、それはログイン後の関数であり、プレイヤーがゲームに参加したときに呼び出されます。


ここには約 8 人が参加していますが、16 人以上が参加できるかどうかを確認したいと思います。


同じ Steam アカウントにログインしている 2 台のコンピューターで参加することはできません。


ほら、17人います。


Steam では許可されていないため、同じ Steam アカウントにログインしている 2 台のコンピューターで参加することはできません。


ただし、先に進んでラップトップでログインでき、別のメールアドレスを持っている場合は、そこから新しいSteamアカウントをすばやく作成できます.


ラップトップでSteamからログアウトしてログインし、新しいアカウントを作成すると、マシンに確認メールが送信されます。


それを確認してログインするだけです。


でも今は18人の選手がいて、これは素晴らしいことです。


要約すると、現在、参加しているプレーヤーの数を追跡しています。


プレイヤーの状態の配列を持つゲーム インスタンスにアクセスすることで、ゲーム モードでこれを行っています。


そのため、その配列のサイズを確認し、プレーヤーの数を画面に出力できます。


また、各プレイヤーの状態を介してプレイヤー名にもアクセスし、それらも表示できるようにしました。


よくできました。


メニュー システムができたので、実際のゲームの作成を開始します。これで、実際の Steam セッション マルチプレイヤーでテストするための基礎ができました。


また後で。

And here in the worldSettings, for gameModeOverride, I'm going to select the lobby game mode, but we need to select BP_LobbyGameMode.


That's because if we select the lobby game mode, C++ class, these would all be grayed out and we can't change that default -- class.


So if we change it to BP_LobbyGameMode, then we can see that our default pawn class is the thirdPersonCharacter.


So very important because if we had the default pawn then we wouldn't be able to see each other move around as the default class doesn't have its movement replicated.


In other words, movement information is not sent to the server when it moves, but thirdPersonCharacter is by default replicated.


That's why we can run and jump around together in the same level.


Okay, so now we've configured the game mode for the lobby level.


We can now go back to the thirdPerson example map.


Okay.


So, for your challenge, I'd like you to go ahead and package the project and zip it up, stick it on a Google drive and go into the discord and find some other students who would be willing to playtest your game.


So see if you could find multiple students.


Remember, there's no limit here.


You just need to set the number of public connections in that menuSetup, blueprint, callable function and the level blueprint.


So test this out, host a session and see if you can track the number of players and see their names and run around.


Have some fun for a little bit and congratulate yourself because this is a huge milestone and you now have a system that you can add to other unreal engine projects.


So pause the video, find some other students, and playtest your menu system.


Now we're ready to test this out, and I'd like to test it with multiple players.


So I'm going to package the game by going to platforms, Windows Package Project and delete the current build that I last built and choose select folder.


Now to test this out, what I did was I held a live session on YouTube and I packaged the game and placed it on my Google Drive and provided it to my students and my discord.


And I had several students join for the live stream.


So what I'm showing you here is footage from that live stream.


And we had quite a bit of players join and run around and test this out with me.


So this is what you're seeing.


So I'm going to be showing you a couple of clips from this live stream.


And if you'd like to watch the entire Live Stream video, you can follow one of the links in the description to watch the entire live stream.


And here we have a couple of people joining in.


So welcome, guys.


Let's see how many we can get in this game build and can see your name at the top left.


And just if you're curious, these messages here at the top left, they're just simply on screen debug messages and they they are being printed from the game mode.


And so that's why you are not seeing these messages on your bill because the game mode actually only exists on the hosting machine, on the server.


And I am a listen server for this game.


So essentially the game mode is printing a debug message and it's post login function and that gets called when a player joins the game.


So we have about eight people in here and I'd like to see if we can get more than 16.


You won't be able to join with two computers that are both logged in to the same steam account.


Look, we have 17.


You won't be able to join with two computers logged into the same steam account because it steam won't allow that.


But if you could go ahead and log in with your laptop and if you want to if you have another email address, you can quickly create a new steam account from there.


Just log out of steam on your laptop and log, create a new account and it will send a verification email to your machine To your email.


You can just verify that and log in.


But we now have 18 players and this is this is great.


So in summary, we are now tracking the number of players coming in.


We're doing this with the game mode by accessing the game instance, which has an array of player states.


So we can check the size of that array and print the number of players to the screen.


And we've also accessed the player names through each player state so that we could display those as well.


Excellent job.


So now that we have a menu system, it's time to start creating our actual game and we now have a basis for testing it through real steam session multiplayer.


I'll see you soon.



0 件のコメント:

コメントを投稿