

Here we access the CubeTransform property we defined in the state in the Bolt Assets and Bolt Editor windows transform - The transform of the GameObject.This part accesses the state of the entity, which is ICubeState Inside the Attached method we are going to add a single line of code: state.SetTransforms(state.CubeTransform, transform), lets break it down: version to methods and not the way Unity does it. Important: Like the SceneLoadLocalDone method from Bolt 101 we use the public override. We are going to implement a specific Bolt method called Attached, you can consider it as the equivalent of the Start method which exists in Unity, but it's called after the game object has been setup inside Bolt and exists on the network. The class we inherit from, which is defined as Bolt.EntityBehaviour in the Bolt source code, takes the type of the state we want to use as it's generic parameter, this just tells Bolt the type of the state we want to access inside our CubeBehaviour script.Īs with the Bolt.GlobalEventListener class from Bolt 101, the Bolt.EntityBehaviour class inherits from MonoBehaviour and you can use all normal Unity methods here too. This gives you easy and statically typed access to all properties of your states. ICubeState is a C# interface created by Bolt automatically when you run Bolt/Compile Assembly, that exposes all of the properties you have defined on the state.

#Networkview owner unity code#
Public class CubeBehaviour : Bolt.EntityBehaviourīefore we go into adding any code inside CubeBehaviour let's look at what exactly Bolt.EntityBehaviour does. Remove the default Unity methods and have the class inherit from Bolt.EntityBehaviour instead of the normal MonoBehaviour. Start by creating a script called CubeBehaviour in the Tutorial/Scripts folder and open it up in your text editor of choice. Now it's time to use the property and introduce ourselves to coding Bolt entities. When we created our Cube prefab, and the state CubeState for it, we've added a property called CubeTransform.

In this part we will look at how we go about replicating (serializing) properties over the network. In Bolt 101 and Bolt 102 we learned the basics of getting Bolt running, how get some properties and game objects replicating over the network. Of course all your PUN & Bolt projects will continue to work and run with the known performance in the future.įor any upcoming or new projects: please switch to Photon Fusion or Quantum. We will support Unity 2022 with PUN 2, but no new features will be added. PUN Classic (v1), PUN 2 and Bolt are in maintenance mode.
