Advertisement
salahzar

ScriptAperturaPortaSincronizzata-rinominami.cs

Mar 6th, 2021
728
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 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.     [UdonSynced] bool IsOpen;
  12.  
  13.     Vector3 OpenPosition = new Vector3(-0.207f, -1.63f, -0.56f);
  14.     Vector3 ClosePosition = new Vector3(-0.207f, 1.197f, -0.56f);
  15.  
  16.     void Start()
  17.     {
  18.         Debug.Log("started VRC_button_A_matt1");
  19.         //DELETED target.localPosition = closePosition;
  20.         //GET ACTUAL POSITION OF THE DOOR WHICH IS NOW SYNCED
  21.         IsOpen = Target.localPosition == OpenPosition;
  22.     }
  23.     public override void Interact()
  24.     {
  25.  
  26.         Debug.Log("Interacted");
  27.         SendCustomNetworkEvent(NetworkEventTarget.All, "NetworkEventStuff");
  28.        
  29.        
  30.     }
  31.     public void NetworkEventStuff()
  32.     {
  33.         if (IsOpen)
  34.         {
  35.             Target.localPosition = ClosePosition;
  36.             IsOpen = false;
  37.         }
  38.         else
  39.         {
  40.             Target.localPosition = OpenPosition;
  41.             IsOpen = true;
  42.         }
  43.        
  44.         Debug.Log("changing position to " + Target.localPosition);
  45.     }
  46.  
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement