PUN Classic (v1)、PUN 2 和 Bolt 處於維護模式。 PUN 2 將支援 Unity 2019 至 2022,但不會添加新功能。 當然,您所有的 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 (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