PUN Classic (v1)、PUN 2 和 Bolt 處於維護模式。 PUN 2 將支援 Unity 2019 至 2022,但不會添加新功能。 當然,您所有的 PUN & Bolt 專案可以用已知性能繼續運行使用。 對於任何即將開始或新的專案:請切換到 Photon Fusion 或 Quantum。

Temporal Anti Aliasing

Note: This should not be confused with graphical anti-aliasing techniques used on the GPU/in the rendering process.

Bolt has built-in support for handling the dis-joint relationship between Update and FixedUpdate in Unity, to put it a bit more bluntly: The simulation (FixedUpdate) and rendering (Update) portion of your game does not always line up 1:1 with each other.
This causes what's commonly known as 'micro-stutter'.

When you define a 'Transform' property on your state in Bolt, you need to assign a transform to it in the Attached callback to have it sync over the network.
Normally a simple prefab would look like this:

Photon Bolt: Simple Prefab
Photon Bolt: Simple Prefab

And the code for hooking up the transform like this:

C#

using UnityEngine;
using System.Collections;

public class Sphere : Bolt.EntityBehaviour<ISphereState> {
  public override void Attached() {
    state.Transform.SetTransforms(state.Transform, transform);
  }
}

If you've used bolt past the first part in the 'Bolt 101' series, this should look very familiar.
Since all simulation happens in FixedUpdate, this setup can lead to 'micro-stutter'.
The way to deal with this is something called Temporal Anti-Aliasing.
Read more about "Temporal Anti-Aliasing".

The first thing we need to do is to just setup a normal class field on our 'Sphere' class, and pass that in as the secondary value to SetTransforms.

C#

public class Sphere : Bolt.EntityBehaviour<ISphereState> {
  [SerializeField]
  Transform renderTransform;

  public override void Attached() {
    state.Transform.SetTransforms(state.Transform, transform, renderTransform);
  }
}

We then split out the mesh rendering parts from our root game object into a child object and make sure to assign the new 'SphereMesh' child object to the 'Render Transform' property we created on our 'Sphere' script, like this:

Photon Bolt: Recommended Prefab
Photon Bolt: Recommended Prefab

Now Bolt will take care of handling all artifacts which happen from FixedUpdate/Update not lining up perfectly.

Back to top