PUN Classic (v1)、Boltはメンテナンスモードとなっております。Unity2022についてはPUN 2でサポートいたしますが、新機能が追加されることはありません。お客様のPUNプロジェクトおよびBoltプロジェクトが停止することはなく、将来にわたってパフォーマンス性能が落ちることはありません。
今後の新しいプロジェクトについては、Photon FusionまたはQuantumへ切り替えていただくようよろしくお願いいたします。
IPriorityCalculator
IPriorityCalculator で、状態同期とエンティティイベントの優先順位を設定できます。マップが広く、たくさんのイベントが発生するようなゲームでは、送信したいすべての状態やエンティティイベントに合わせてバイトを調整することができません。送るものがないときは0を返します。
C#
public class EnemyController : Bolt.EntityEventListener<IEnemyTest>, Bolt.IPriorityCalculator
{
/**
* Calculates the Priority of a State update
* be sent into a package
* @param connection Target player connection
* @param skipped Total times the data was skipped
* on the packing process
* @return The priority number
*/
public float CalculateStatePriority(BoltConnection connection, int skipped)
{
// default implementation
// return skipped;
// returns priority based off
// of distance to connection's player
return 1000 - myDistanceTo(connection) + skipped;
}
/**
* Calculates the Priority of a Event
* be sent into a package
* @param connection Target player connection
* @param evnt The event to be sent
* @return The priority number
*/
public float CalculateEventPriority(BoltConnection connection, Bolt.Event evnt)
{
// this enemy has entity events for sounds, so this will
// always be low priority but will be higher priority than
// other sounds based on distance to connection's player
// myDistance has a maximum of 1000 in this example
return (1-(myDistanceTo(connection) / 1000f));
}
}
Back to top