VRChat Intro To UdonSharp: Toggle a Mirror

Ойындар

A quick rundown on writing your first script with UdonSharp.
Remember to save your script before testing and ending statements and variables with ";"!
The interact method will only work on an object with a collider component on it.
UdonSharp
github.com/vrchat-community/U...
Visual Studio
visualstudio.microsoft.com/vs...
00:00 Who is this for?
00:12 Why UdonSharp?
00:35 Download and Install UdonSharp
01:10 Download and Install Visual Studio
02:05 Adding Udon Component
02:45 Anatomy of a Script
03:23 Adding the Interact Method
05:18 Adding a Variable for Mirror
06:54 Turning Mirror On Statement
07:59 Adding A Bool
09:04 Adding an If/Else Statement
10:57 Finishing the If/Else Statement
11:44 Final Notes

Пікірлер: 21

  • @samuelprod
    @samuelprod4 ай бұрын

    Coming back to world dev after years of just doing avis, thank you for the tutorials you have made. I will be watching them over the next couple weeks and u deserve way more credit bro you are appreciated

  • @the_stray_cat
    @the_stray_cat Жыл бұрын

    thank you! this is an amazing intro that actualy Just goes over udon sharp , no bells and whistles. other vids seam to just try and teach everything at once

  • @ZorgyBabyVR

    @ZorgyBabyVR

    Жыл бұрын

    Thanks! That's the reason why I made this. Some videos really take forever to go over stuff and I don't have the attention span for it haha.

  • @the_stray_cat

    @the_stray_cat

    Жыл бұрын

    @@ZorgyBabyVR lmao same here hehe. i used to have a l9ong atention span but been watching to many shorts XD

  • @Enstrayed
    @Enstrayed Жыл бұрын

    Thanks for the guide. I was kinda scared of U# at first but your video put the pieces together for me and now my mirrors have toggles!

  • @Vundeq
    @Vundeq Жыл бұрын

    great tutorial, deserves more recognition. Cheers.

  • @Vundeq
    @Vundeq Жыл бұрын

    Alternatively, instead of using if statements, you can simply invert the bool and set the activity of the mirror like so public override void Interact() { MirrorEnabled = !MirrorEnabled; // inverts the bool FunnyCube.SetActive(MirrorEnabled); // sets the mirrors enabled value }

  • @ZorgyBabyVR

    @ZorgyBabyVR

    Жыл бұрын

    Thanks for sharing! I tried to make it as easily readable as possible for beginners, but its not the best way to write it.

  • @LunaDaSpooky

    @LunaDaSpooky

    7 ай бұрын

    A year later, even more condensed public override void Interact() { gameObject.SetActive(!gameObject.activeSelf); }

  • @BerryTheBnnuy
    @BerryTheBnnuy8 ай бұрын

    Instead of all those ifs, you can actually toggle it and set the bool in a single line... I mainly just used this tutorial to learn how to use udon sharp real quickly... Here's my mirror button class... using UdonSharp; using UnityEngine; using VRC.SDKBase; using VRC.Udon; public class MirrorButton : UdonSharpBehaviour { public GameObject mirror; private bool _enabled = false; public override void Interact() { mirror.SetActive(_enabled = !_enabled); } }

  • @ZorgyBabyVR

    @ZorgyBabyVR

    8 ай бұрын

    Absolutely! There are many ways to do it! I chose to use the If statement way for people who have never done any coding, I feel like it is a little easier to understand for the beginner. If you watch 12:18 to the very end of the video show a 3rd way of doing this same thing, many ways to skin a cat haha. glad you could use the video to familiarize your self with udon!

  • @BerryTheBnnuy

    @BerryTheBnnuy

    8 ай бұрын

    @@ZorgyBabyVR I can't find a scripting reference for it... I pretty much refuse to use the graph. Also, I've made the bool public so I can have a trigger collider that when the player walks through it, it shuts the mirror off for them. That way mirrors shut off when you live the room it's in so they don't cause performance issues. Took a while without a reference manual to figure out to even use the OnPlayerTriggerEnter event, which I got from a video showing how to do it in a graph... and took a while to figure out the event has VRCPlayerApi as an argument... I don't suppose you know of a reference manual anywhere?

  • @ZorgyBabyVR

    @ZorgyBabyVR

    8 ай бұрын

    @@BerryTheBnnuy this is the Udon sharp documentation udonsharp.docs.vrchat.com/events I am not a fan of the graph either. You probably have a reason to use the collider to turn the mirror off, I prefer to use the update loop to check how far is the player and then have the mirror turn off when the player is to far away. I use it in the Summer House world if you care to check it out.

  • @BerryTheBnnuy

    @BerryTheBnnuy

    8 ай бұрын

    @@ZorgyBabyVR Well I figure a collider isn't running code every frame, which is why I don't use update. Also I've got a pair of mirrors in fairly close proximity to each other and I want them to turn off when you approach the area that has the other. I've got the colliders for it hidden in dog legs so you can't see either area the mirror is in by the time you trigger it being shut off. If you want to check out the world I'm working on, it's Tatooine Starport, by Berry Bnuuy. The mirrors are in the ship that you can board once you leave the starport. It's a work in progress. Less than a week old, and it's my first world, so I've got some issues I'm trying to work out. Like I'm having trouble getting the seats to not put your butt inside of them. And there's some sounds but they don't play except in the Unity editor... can't seem to find any tutorials on using the VRC spatialized sound component properly.

  • @jeshirekitenkatt1212
    @jeshirekitenkatt12124 ай бұрын

    notepad++ is also excellent if you don't want to go get visual studio tbh. it comes with every language under the sun plus you can easily install plugins for any languages you want to add. something i have NEVER understood between this and java is this whole public / private class stuff. i have never been able to find a plain English description of what a "class" even is (it doesn't seem to be the same as a lua or lsl function, and it seems "function" as a term also has a completely different definition here maybe???), what public vs private means and how it effects anything within those classes nor any straightforward examples to help me understand the concept. until i can get an explanation of *that*, i don't think i can wrap my head around any of these languages that use them. it's just throwing a bunch of jargon that i don't know what it does at me and expecting me to just follow along. what does any of this sh*t mean???

  • @ZetsKai
    @ZetsKai4 ай бұрын

    My VRCC looks... really different and I cant find any package that says U#

  • @ZorgyBabyVR

    @ZorgyBabyVR

    4 ай бұрын

    I believe U# comes in the default package now. So you dont need anything additional, then the default package.

  • @Matthew.1994
    @Matthew.1994 Жыл бұрын

    how can i make it that the mirror toggles for everyone in the world when 1 player toggles it?

  • @ZorgyBabyVR

    @ZorgyBabyVR

    Жыл бұрын

    You would send a "custom network event". Once someone clicks the mirror on a command would be sent to all other players to then turn the mirror on. Probably needs a video on its own to explain. You will have to write an additional new method that will have all the code you already wrote in the "Interact" method and delete the code in the interact method and replace it with a custom network event that calls to that new method. The problem with the below code is that it doesn't compensate for late joiners. so if you turn the mirror on, then a friend joins, they will see the mirror off, when you click it again, the mirror will be off for you but on for your friend. I would go in to how to fix this but this is already a long response haha public override void Interact() { SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.All, "MirrorStuff"); //"All" means that every player in the world will run the "MirrorStuff" method below } public void MirrorStuff() { if (mirrorIsOn == false) { superHotMirror.SetActive(true); mirrorIsOn = true; } else { superHotMirror.SetActive(false); mirrorIsOn = false; } }

  • @TinyGiraffes
    @TinyGiraffes Жыл бұрын

    Needs information *Gets it* Where is bullshit extra stuff? You can't have a video without bullshit extra stuff!?!?

  • @ZorgyBabyVR

    @ZorgyBabyVR

    Жыл бұрын

    Haha XD i hope that means you liked it

Келесі