PUN Classic (v1)、PUN 2、Boltはメンテナンスモードとなっております。Unity2022についてはPUN 2でサポートいたしますが、新機能が追加されることはありません。お客様のPUNプロジェクトおよびBoltプロジェクトが停止することはなく、将来にわたってパフォーマンス性能が落ちることはありません。
今後の新しいプロジェクトについては、Photon FusionまたはQuantumへ切り替えていただくようよろしくお願いいたします。
Alternative SimulateController / ExecuteCommand
"Abuse" the executecommand in bolt
Usually you use ExecuteCommand()
& SimulateController()
to do the type of authoritative client-side predicted movement that say an FPS or TPS would but you can use it like that, basically ignoring the "resetState" and just have that as a target to "get to".
C#
public override void SimulateController() {
IMyVehicleCommandInput input = MyVehicleCommand.Create();
input.Throttle = ...
input.Gear = ...
input.Blah = ...;
entity.QueueInput(input);
}
MyVehicleCommand serverResult;
public override void ExecuteCommand(Bolt.Command command, bool resetState) {
MyVehicleCommand cmd = (MyVehicleCommand)command;
// resetState means we got a state update from the server, this will only be true on the client
if (resetState) {
serverResult = cmd;
}
if (command.IsFirstExecution) {
// and because resetState is only true on the client, this will not be called on host
// also only be true on the client
if (serverResult != null) {
// if we have a server result, this is the last "verified"
// result from the server, the data will be available in
// cmd.Result and is specified by you on the Command asset.
// this is your lerp target
}
// perform movement logic for player, this code execute on both client (controlling) and server
}
}
Back to top