Advertisement
salahzar

Syncing via network messages. Rename the class name before using.cs

Mar 2nd, 2021
978
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1.  
  2. using UdonSharp;
  3. using UnityEngine;
  4. using VRC.SDKBase;
  5. using VRC.Udon;
  6. using VRC.Udon.Common.Interfaces;
  7.  
  8. public class VRC_button_A_matt1 : UdonSharpBehaviour
  9. {
  10.     public Transform target;
  11.  
  12.     Vector3 aperta = new Vector3(-0.207f, -1.63f, -0.56f);
  13.     Vector3 chiusa = new Vector3(-0.207f, 1.197f, -0.56f);
  14.  
  15.     void Start()
  16.     {
  17.         Debug.Log("started VRC_button_A_matt1");
  18.         target.localPosition = chiusa;
  19.     }
  20.     public override void Interact()
  21.     {
  22.  
  23.         Debug.Log("Interacted");
  24.             SendCustomNetworkEvent(NetworkEventTarget.All, "NetworkEventStuff");
  25.        
  26.        
  27.     }
  28.     public void NetworkEventStuff()
  29.     {
  30.         if (target.localPosition == aperta)
  31.         {
  32.             target.localPosition = chiusa;
  33.         }
  34.         else
  35.         {
  36.             target.localPosition = aperta;
  37.         }
  38.         Debug.Log("changing position to " + target.localPosition);
  39.     }
  40.  
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement