Files
Netick.Unity/Samples~/Bomberman/Scripts/Block.cs
Karrar daa599f0fc Read the description for commit details.
- Added `OnSceneOperationBegan` and `OnSceneOperationDone`. These are network events for when a scene load/unload operation begins and when it is finished, they offer more information than the older equivalent methods. `OnSceneLoadStarted` and `OnSceneLoaded` are now marked as `[Obsolete]` and will be removed in the future.
- Added `Teleport` method to `NetworkTransform`, `NetworkRigidbody`, and `NetworkRigidbody2D`. This allows you to skip interpolation for one tick.
- Fixed an issue causing scene objects to not get destroyed for late joiners.
2024-04-28 12:06:20 +03:00

26 lines
743 B
C#

using UnityEngine;
using Netick;
using Netick.Unity;
namespace Netick.Samples.Bomberman
{
public class Block : NetworkBehaviour
{
// Networked properties
[Networked]
public NetworkBool Visible { get; set; } = true;
[OnChanged(nameof(Visible))]
private void OnVisibleChanged(OnChangedData onChangedData)
{
// for visual components, don't use "enabled" property when you want to disable/enable it, instead use SetEnabled().
// -- GetComponent<Renderer>().enabled = Visible; #### Not like this.
GetComponent<Renderer>().SetEnabled(Sandbox, Visible); // #### Like this.
GetComponent<BoxCollider>().enabled = Visible;
}
}
}