#udon-general
59 messages · Page 100 of 1
Hah, not a terrible idea, just seems odd we have to resort to that
Yeah, locating stuff at root level is a bit limited. Some methods are available though.
Like GameObject.Find is possible.
oh alright one sec lemme try
How would I make a VRCObjectPool loop itself and go back to the first object on the list, if all the objects have already been spawned?
Right now mine just breaks the Udon behavior when it finishes the list and I try to spawn it again...
I got it to work. Thanks for the tip! I really was asking the wrong question.
hi im new to unity and im trying to figure out how to toggle between cameras in game
Honestly, when trying to make these more complicated pool scripts, I tend to just create my own object pool script via udon, as it makes it easier to do more advanced stuff. I did once make one that checked what part of the pool the last object to spawn in was, and forced the one ahead of it to return, thus there was always an object to spawn in. you can use VRC.ObjectPool, get pool to get the pool list to see what object the next one is. might be useful for ya.
Also, the reason your script crashes is that the object pool failed to spawn an object, which would be fine, except your then trying to make that non-existent gameObject active (which is redundant btw, as that's what the pool does) and then change its location. adding an 'isValid' check can stop this problem, like I did for this one:
what exactly do you mean? VRChat, being a vr game, is first person only
its hard to explain but for streaming so u have the little phone cameras where u can pin three of the, but i want like six cameras that i can switch between. its to go in a podcast world.
ah, so you want to have say some buttons that you can click to go in-between the different cameras. quick question, are all the camera's settings going to be the same, or are some going to have a greater field of view?
yes like that and all the settings will be the same and be able to pick them up
okay, so you also want to pick them up.. okay, so I'm assuming you have 6 or so cameras, each having a rendered texture on them. then you just need to have the vr camera recording a plane or something (better yet a shader, dunno one to link though). All you then need to do is switch out the material for the different outputs, depending on the camera active
ok thx but how would i get buttons to switch them would it be similar to HQ and LQ mirror
kinda... but also a lot more complicated. let me do a doodle in udon to roughly what you want.
you will need to however create a rendered texture for each camera, and somewhere for it to display that texture
ok thx alot for this been trying to figure it out for a couple of hrs XD
So here's what I came up with. basically I have 3 lists, a list of cameras, a list of materials from those cameras, and a list of the displays for those cameras, so that people on the podcast can also see the camera's output, without have to see the one being used to record it directly. I also added a simple script to select the next camera, so that you can test it all with just this script:
then you would want to have a script like this on each button, that tells the camera manager script (the one above), a new camera that it would like. I've added both a custom event and an interact event, so you can call it from a ui button, or an object that serves as a button
thx alot for that
Here's the two files. they are completely untested though, so let me know if there is a problem
also, the camera changes are networked as well, so everyone should see the changes happen
kk
how would i have an object snap to a grid when released? this is my current setup for it but its both limited to the world grid and just straight up doesnt work
I think Translate moves relative to the current position, you probably want to set the position instead
is there one that only sets it 1 axis at a time?
or just be able to turn 3 floats into a float3
I'm not sure, I haven't used the graph
found it, its a vector 3 constructor node
hte vrchat docs dont really explain it, but what does the "event on enabled" do?
also, here's a shader that should hopefully work for the camera. Just put it on a sphere and put the camera inside the sphere (facing the right way to the people so the audio is correct)
on enable gets called when an object that was disable, becomes enabled (setactive = true)
ok, so if i put the udon behaviour on a disabled object, the event will only be sent once if its enabled and for it to send again it needs to be disabled and then re enabled right? bc thats exactly what i need
yup ^^
im trying to keep the last safe position of an object stored, so that if the object goes out of bounds, it warps back to that last safe position
how do i keep that last safe position stored?
this is my current setup for it, but it doesnt seem to work
wrong node. Drag and drop the lastPos variable into the graph while holding ctrl, to get a node that will set that variable's value
ah alright
i tried that but i thought it was shift and not ctrl so that makes sense :x
Actually, might be wrong on that one. Just looked up the documentation and perhaps vector3,set node should work. Haven't used it myself though, so I can't say for udon... https://docs.unity3d.com/ScriptReference/Vector3.Set.html
vector3.set was the one i used in the screenshot, and that one didnt work (of course i might have just used it wrong but still)
the one from holding down ctrl worked, though
Interesting... wonder why
Can you create own custom name tags in your world. Like for example: Creator,
Is anyone taking avatar commisions?
How do I add in an avatar pedestal? Trying to add one into my commissioned world. I type in pedestal in the vrcsdk and it shows up, but when I click on it I don't see it appear in the actual world in unity.
There is an example prefab under vrchat examples, prefabs that you can use as a reference
How do I disable instance culling for a specific object?
I've asked in #shaders aswell but this might be a code thing
I'm not familiar with anything called "instance culling" are you talking about occlusion culling or something similar?
whatever it is that causes meshes outside the view to stop being rendered
that would be frustum culling then
I'm using vertex shaders to heavily manipulate their positions
oh ok sorry ^^'
that said I've searched for that term aswell and haven't found a solution
the solution is to increase the mesh bounds. If this is a skinned mesh renderer, that's easy and can be done in the inspector
if it's a regular mesh renderer you'd need to do something different. I'm not sure if you can modify renderer bounds but you can at least get mesh bounds with this, and you could try to set it and see what happens https://docs.unity3d.com/ScriptReference/Renderer-bounds.html
the skinned mesh renderer thing worked !! though I don't know if its a bad idea to just replace it
also I have a particle system that renders meshes aswell which this won't work on
lol, just using a skinned mesh renderer for a regular mesh might actually just be the solution. Bit of a hack but if there's not too many vertices it shouldn't have a huge performance impact
yeah it's gonna be a fine workaround
❤️❤️this already kind of saved the project tysm
I think the real solution, especially for particles, is to just not use geometry shaders that extrude too far outside the bounds. Depends on the geometry you want to do but perhaps you can have the base mesh be larger and then have the shader go in reverse?
I might just make my own little system for randomly distributing objects which is what I have been using the particles for
hey does anyone know the code for a trigger zone teleport to one player?
if nobody understand what i mean since i suck at explaining, bascially a person touches a block or goes into a trigger zone, then gets teleported
nah, it's pretty simple. here:
k thanks ill try it
Heyo.
Was curious about using an audio mixer in my world.
Looked around a bit and stuff. But seems like no one is doing it. And I cant get it to compile in U#.
I don't get the "is not exposed" thing. I only get that that it can't be resolved.
So I just assume we can't access/use it? Do anyone know?
TypeResolverException: Type referenced by 'UnityEngineAudioAudioMixer' could not be resolved.
using UnityEngine;
using UnityEngine.Audio;
using VRC.SDKBase;
using VRC.Udon;
public class test : UdonSharpBehaviour
{
public AudioMixer testMixer;
void Start()
{
}
}```
Audio Mixer component can't be used in VRChat
Okok, then I'll have to take the long way around. Thanks!
It let's me upload with one. But I guess its stripped on upload.
There is a whitelist https://docs.vrchat.com/docs/whitelisted-world-components
Anything outside of this list will not be loaded
The following is the complete list of scripts usable within worlds. Components that are not in this list will not work. Unity Components WindZoneVideoPlayerTilemapTilemapRendererTerrainTreeSpriteMaskParticleEmitterEllipsoidParticleEmitterMeshParticleEmitterParticleAnimatorParticleRendererWorldPartic...
Okok, I'll look through it later. Thanks.
Compile errors could be anything, you need to check your console to see what the actual problem is
it's failing to compile the udon sharp scripts according to the console
and?
im having an issue where it just dosnt teleport, is this an issue with the location or something else
this is the udon code
also the location is public
mind showing the inspector of the object that this is script is on
I wanted to see the udon part...
hmm.. seems to be something else. everything looks fine here
should i just remake it from the screenshot on another block?
don't really see how that would help tbh
idk either but ill try it since its easy to remake
i gotta go tho so ill ping (if its alr) once ive tested it
don't really know how I can help more though...
k
currently very confused. does anybody know what i messed up because i cant use the slider in game, every other ui element works fine, exept the slider, its static and not movable
Been searching exposure tree, but any alternatives to ColorUtility.ToHtmlStringRGBA(Color color)?
I need to get the hex value of the color....
if nothing else, could convert the 0-255 values to hex manually
Yeah I am tinkering with that right now, I will share if it works.
Fingers crossed, doing a test run lol
lmao
string.Format("#{0:X2}{1:X2}{2:X2}", (byte)(c.r * 255), (byte)(c.g * 255), (byte)(c.b * 255))
I guess single ` works.
But yeah, something like the above is how I did it.
Works beautifully! Thank you
By the way, the original code also clamps the individual color values with Mathf.Clamp01. Idk why because they are already between 0 and 1 if I'm not wrong.
It's a feature 😄
Is there a way to make a material or object visible to all cameras but the player?
There is HDR color that can exceed 0-1 range.
umm question anyone here that knows vrchat world creation and how to set up mirrors to where they are automatically off when you spawn in? i got it set up and working perfectly but ether the HQ or LQ one is one when you join
*Note: my 1st time doing this so i know little but i got them to work just not how to have them off from the start
thanks alot
ok now i want to add audio to my world how can i do that?
How punishing is it for UDON to reallocate arrays when resizing to add/remove elements?
Since I can't use collections or lists 😛
Note: This is going to be called a lot when dealing with people joining/leaving and receiving their inventory items
Please dont not like this 
Use Array.Copy
@dawn forge Do you use U# 1.0 or not ?
public static class Extensions
{
public static T[] Add<T>(this T[] array, T item)
{
T[] newArray = new T[array.Length + 1];
Array.Copy(array, newArray, array.Length);
newArray[array.Length] = item;
return newArray;
}
public static T[] Remove<T>(this T[] array, int index)
{
T[] newArray = new T[array.Length - 1];
Array.Copy(array, newArray, index);
Array.Copy(array, index + 1, newArray, index, newArray.Length - index);
return newArray;
}
}
U# 1.0 Only
(reposting from another server)
Basically the same as what was posted above, but this is U# 0.x compatible version that I use for handling any type.
protected System.Array AddArrayItem(System.Array stale, int index, System.Object insert)
{
int oldLength = stale.Length;
int newLength = oldLength + 1;
if (index > oldLength) index = oldLength; // prevent out of bounds issue
if (index < 0) index = newLength + index; // enable negative indexes
System.Array fresh = System.Array.CreateInstance(typeof(System.Object), newLength);
// copy from start to the index
System.Array.Copy(stale, 0, fresh, 0, index);
// if element was anything but the last element, copy the remainder after the index
if (index < oldLength) System.Array.Copy(stale, index + 1, fresh, index + 1, oldLength - index);
if (insert != null) fresh.SetValue(insert, index);
return fresh;
}
protected System.Array RemoveArrayItem(System.Array stale, int index)
{
int oldLength = stale.Length;
if (oldLength == 0) return stale; // nothing to remove
int newLength = oldLength - 1;
System.Array fresh = System.Array.CreateInstance(typeof(System.Object), newLength);
if (newLength == 0) return fresh; // new array has nothing to copy
if (index > newLength) index = newLength; // prevent out of bounds issue
if (index < 0) index = oldLength + index; // enable negative indexes
// copy from start to the index
System.Array.Copy(stale, 0, fresh, 0, index);
// if element was anything but the last element, copy the remainder after the index
if (index < newLength) System.Array.Copy(stale, index + 1, fresh, index, newLength - index);
return fresh;
}
Add is 14 externs, Remove is 13 externs. If you don't care about safety checks, could optimize to 8 externs.
Only thing extra you have to do is type cast the response to whatever the stale array's type was. For example:
string[] texts = (string[])RemoveArrayItem(texts, -1);
Alternatively, if you don't care about the ordering of the array, you could do this:
protected System.Array AddArrayItemUnordered(System.Array stale, System.Object insert)
{
int oldLength = stale.Length;
int newLength = oldLength + 1;
System.Array fresh = System.Array.CreateInstance(typeof(System.Object), newLength);
System.Array.Copy(stale, fresh, oldLength);
fresh.SetValue(insert, oldLength);
return fresh;
}
protected System.Array RemoveArrayItemUnordered(System.Array stale, int index)
{
int newLength = stale.Length - 1;
System.Array fresh = System.Array.CreateInstance(typeof(System.Object), newLength);
System.Array.Copy(stale, newLength, stale, index, 1);
System.Array.Copy(stale, fresh, newLength);
return fresh;
}
these have Add and Remove both being 5 externs only.

what wrong in these
I do, thank you very much for this!@
how do i set a button to only turn objects off
List
VRChat does not support List
disapointment
if I were making a chessboard, what would be a way to check what tile a piece is currently on? the tiles are all individual objects in an array, if that helps
Just use the position and math it out based on that or iterate through all objects and check distances and use the one with the smallest distance
Those are 2 ways
First way is faster runtime
a for node would be good for that, right?
Are you making a chessboard in nodes?
yeah, but the tiles move up and down, so im trying to get the height of the tile the piece is on so it stays on top of it and doesnt clip in
the positions are super simple and i already have a setup in the first way you mentioned, but it wasnt working so i was hoping there was a different way lol
prob just gonna need to dig through the nodes again and figure out which one is breaking it
the way I have it set up right now is that when the piece is released, it snaps to the nearest X and Z position so it matches with the tiles, then it uses a for node to check every tile and see if their X and Z position matches the piece's, and when a tile matches it then it grabs the Y of that tile and snaps the piece to it
if theres a better way to do this lmk
TempPos is just the X and Z of the snapped piece
is everyone able to edit udonsynced variable or only host or object owner
Only object owner
okay time to make ingame console
how would i make one
so it will have scrolling and all that
anyone know why the spheres i spawned down a ramp dont respawn?
what you do with them
they just use physics to fall off the map
Hi guys does any one know if the obunga avatar is in the game and if so where to find it?
Give it a pickup and uncheck Pickupable
k thanks
can i have multiple ondeserializations in separate files
Hey Miner, thanks for your input. What if I want to remove the element based on the string/content of the array?
as im requesting serialization and it never finishes
they infinitley fall
also am i able to give them collision?
when they dont infinitley fall
i think when you add object sync it should definelly teleport back
with or without pickup needed?
it works without pickup but why do they have no collison with players (for context on why im asking this is just i wanna make a parkour course and a part was gonna be the spheres pushing players off
how do i do local audio? i'm trying to make volumes that fade in audio sources when entered, but they affect all players even when their sync methods are set to none
dont use sync
Maybe you're using code that checks for all players instead of just local?
I dont think audio emitters can be synced at all anuked
i dont want that
maybe i should check if vrcplayer matches the local player?
yes! that should be it
just check player.isLocal
I am use to developing with MVC architecture, and wanted to know how I can approach this in Udon
I am basically trying to achieve something equivalent to defining and initializing a class to store in a collection that tracks player data such as name, rank, and level.
What would be the best practice? I think what I am currently doing is too silly with representing gameObjects for instances of my script while I use the scene as a collection, and creating/destroying which can be costly to the CPU.
Check the layers it may have defaulted to Pickup layer, which doesn't collide with players
Best practice (assuming you are optimizing with udon and vrc in mind) is to have a pool of objects and connect them. Or to have a pool of a single class that has all of the basic player data.
k
If you don't need to sync this data you can have just one object that manages the local player's data and stats.
I have a question why not add the physical things necessary for when we are against a wall how about the collider could make bone physics be moved while against the wall
I need the owner of the "Scoreboard" object to ask for all player objects available in the collection, so I can enumerate the player objects to list them visually with their name, rank, level and then share the updated view to everyone else.
Since the object pool is configured only during runtime, are you referring to taking an object when a player joins, update the properties of the object(class) and use that?
Yes, to elaborate: have an obj pool greater than the max size the world can support. Each player takes the next avaliable one upon join and updates the values as needed (manually sync this when it changes). Then just call a function on another class that has references to all other scores and organize them to your liking.
Sweet thank you 😄
whats the difference between a 'conditional and' node and a 'logical and' node?
so i know how to teleport players in a world when they click to interact with an object, is there a way to change to wear it teleports them if they only touch it?
Do you mean like a trigger? You can use OnPlayerTriggerEnter for that.
Those are the same as && and a single & in C#. Conditionals are mainly used for bools (true/false) while logical are used to flip bits. For example, the number 3 is 011 and number 5 is 101, so if you do 3 & 5 you get 1 which is 001.
There are some more technical details to them, like && can escape early without calculating what is the second operation, while & can't.
Anyway, hope it made sense. I'm sure you can find more explanations online as it's a general programming concept, not just Udon.
do i change the interact then?
would this work? its supposed to set every object in the array to the same height, but something is messing up with the For node
Yeah, replace Interact with OnPlayerTriggerEnter.
It does look fine to me. Do you have any errors?
Okay! I’ll check it out and check it works
not from what I can tell, errors would show up in the unity console when its built and tested in vrc right?
is there something else I should change? it doesn't seem to work when testing
Do you have a collider? The gameobject needs one so it knows when the player entered.
This would probably be useful: https://www.youtube.com/watch?v=1QSbuwij_Xc
You can use something like the CyanEmu, or the new thing (don't remember name) if you are using the companion. They allow you to test in the editor.
clientsim?
At least one is working! Part of the issue is it automatically turned off the is trigger when I changed the scripts
Way! It works, just changed collider sizes, thank you!!!
Just make sure you are only teleporting when the local player goes into it. OnPlayerTriggerEnter also fires when someone else enters it on your screen.
Yeah, that one. It will show you errors when using it.
does Event.OnSpawn trigger when an object is respawned?
update: yes it does, I don't know why I asked if I could test it right away :x
would i need to check by having someone else try it?
You can do Build and Test instead of uploading and choose multiple clients.
But if you have a look at the video I linked, I'm pretty sure he explains the proper nodes to handle that case.
do i have to delete the vrc sdk from the project to use it? its saying theres a ton of conflicting files when i start it using clientsim
I haven't tried the companion so I don't know. Try posting those errors.
genuinely just hundreds of these
looking it up in this server and its apparently conflicting with the default vrc sdk
Yeah, definitely looks like you have to remove the previous files
companion is storing the sdk somewhere else, so no need to import the package anymore
would deleting the sdk mean i lose the udon code or will they be fine
Yeah no it teleports everyone
when in doubt, make a backup ^^'
kk i got it all working, no errors show up in the console when it starts though
but the for node still doesnt seem to work
is it fine if the objects in the public array are children of the object thats hosting the array?
cause when i put the code for the array on a new object (and sometimes when i restart unity) it clears the array
on the board object vs when i put the same script on a new object
Wanted to say thank you 😄 Just got off work and here is what I have so far, is this the best implementation?
Edit: I just stuffed in a return in my for loop lol
make sure that you check if they are the local player first before getting a new pooled obj
Like this? if (Networking.LocalPlayer.IsOwner(playerPoolObject.gameObject) && Networking.LocalPlayer.isLocal) {
ok after some testing ive realized that its not the For node messing up, but the set Y node
or any of the nodes between Get transform and set Y
but idk whats wrong with that setup
ok this setup works and moves the tile
but this one doesnt?
im like ripping hairs out why doesnt it work
but this works?!?!?!
im just gonna assume the vector3.set nodes are cursed
why ondeserialization not work
Ima try to emulate this to see what happens
heres the whole node setup
Ok so I studied it, and the second attempt won't work because the y is readonly unless you do .Set (Set position in the node case)
Brain is fried from work, sorry I can't express in a graph but hopefully this will give insight on the logic.(This is UdonSharp/C#) Here is a few examples and there is one I show where it wouldn't work
Is your behavior set to manual sync?
OHHHHHH i get it now
thanks a ton man!
I also saw you using position and localposition. Localposition is set relative to its parent, not the world space. Just a FYI
automatic
i have deserialize in 2 scripts
in first one all works
in other one nothing works
i made simple check and it fails
These two scripts in same game object?
no
two deserializations in two different scripts
and thinking it might break stuff
as it gets quite laggy then too
yepyep, i was partway thru switching all my code to using localposition when i took the sc lmao
Is there a way to make VCRUrls in the node editor? since it isnt possible in udonsharp
getting this error even though the Get node is set to an instance
What index are you passing into Get @shy osprey ?
Got any debugging setup? Check and see if recursion is happening or Network.IsClogged = true?
For node
Anyone know how I might be able to get a collider to go through another collider? I'm trying to get an object to be able to trigger an Udon script when I throw it through another object but it always bounces off because they both have colliders and doesn't seem to trigger the OnCollisionEnter event in Udon. If there's another way to do something similar that would be fine too
same error pops up if i get the end it from the array itself, but this time the error is in the get length node
@shy osprey Do you have your gameobjects populated in the inspector for the gameobjects of Tiles? It's not able to get the length from Tiles.
its pulling Tiles from a separate script, and it is populated
I've never used Get Program variable real time, I am use to referencing each other by grabbing the behavior component out of the object and interact with it that way.. hmm
TilesGet is your source of the variable I assume, and that is referenced in the inspector and the item is active?
i dont really know how it works, i mostly just followed tis tutorial https://youtu.be/HERcbs636Xo
Here's a short tutorial covering how to get a program variable from another script. Something to note, is that the variable you wish to get needs to be a public variable for other scripts to be able to see it. Also, I didn't show it as I never put my script on a game object, but you would have to fill out the public udon variable when you go and...
i dont need the variable real time though, so how would you get the array from the udon behavior component?
I basically call gameObject.GetComponent<T> to look for my behavior and reference it. I can then update the variables or get them
For instance, I am looking for a TextMeshUGUI component so I can update the text strings on it, I am doing this..
Again, apologies I can't express well in nodes but the methods/keywords should help you since the nodes references same methods by Unity and Udon.
Last line is a very direct way to read the playerName variable
so would it be like this?
Don't think that'll work, as GameObject[] is not a component type
then is there another way to get a GameObject[] variable if its in a different script?
Just a UdonBehaviour.GetProgramVariable?
like this one? this is what i was using before but it was causing errors
hm that should've just worked
I'm not very experienced with nodes.. as they seem too much work to deal with.
thats what i usually hear abt it lol, ive used blender and it's node system for years now so this is more intuitive than learning how to code for me
but yeah its got its own set of weird hangups
You can also just set the gameObject[] array again for this object
you can select multiple gameobjects and drag them onto the array name and it should add all of them
yeah i might just end up doing that, this is causing way more trouble than its worth

also thank you for telling me this bc i did NOT know that and the full board is 10x10 lmao
would have had to manually put in 100 objects multiple times
dumb question but how do i do this? selecting all the gameobjects deselects the one with the variable
that will lock the view at that time and any selection will not make it change
hm, selecting multiple and dragging it onto it doesnt seem to work
it only puts the first one selected in the slot i let go over
I thought it'd work.. maybe it's U# only
it seems that it should work, i looked up a video for it and thats how its done
but i dont see how it being a graph changes it
i hope and pray i can find a way to do that before i actually need to put all 100 objects in the array
?
would that still be accessible in the node graph?
If you make your array public and not hidden in inspector.
Yeah it's a U# thing for populating the arrays with drag n drop, didn't work with the graph
it worked with the pools though, now i just gotta figure out how to access the pool in the script
i would just drag this into the editor right?
how did you get the Tiles node into the graph?
It's a defined variable in the graph I dragged and dropped onto
Yeah, they start inactive.
would just doing a for loop at the start to make them active work?
Nope, the pool will assign you an object on a successful spawn via GameObject type.
Yeah but you'd want to leave it to their component, because it does additional checks and also sync's these updates for you via the TryToSpawn method.
But you can recursively call TryToSpawn to be on the safe side till you got them all.
does TryToSpawn just call a random object or does it do all of them at once
Good question, I have yet to test it really to see if it goes in order, but it just picks one at a time.
VRC Object Pool provides a lightweight method of managing an array of game objects. The pool will manage and synchronize the active state of each object it holds.
To make an object active, the Owner of the pool triggers the TryToSpawn node, which will return the object that was made active, or a null object if none are available. Objects may be returned to the pool by the pool's owner, and automatically disabled, via the Return node.
Late joiners will have the objects automatically made active or inactive where appropriate.
This doc covers Networking Components, Properties and Events you can use in your Udon Programs. Special properties you can get from Networking: IsClogged - returns true if there is too much data trying to get out. You can use this to hold off some operations or adjust your logic. IsInstanceOwner - r...
Although I will have to see tomorrow on the true behavior, because I started digging into all this, literally.
I'd TryToSpawn one a time so that I can hydrate/refresh the properties of the program so that the next player doesn't have someone else's name noted in the scoreboard
Just like this example, it doesn't matter what's in the object, I am just setting the values again.
But if you need something to show and hide, but want it to go to a corresponding player every time, you could note the player name and then do a loop and if.
im wondering this cause the node for it doesnt have an input for what it spawns
all you can input is the instance of the pool itself
Its the objects you referenced in the inspector in the scene.
so it does do all of them at once?
1.Think of glowsticks at a party, you got them all in the bucket by the door.
2.During the party, you can't add anymore sticks to the bucket.
3.But visitors can borrow one.
4. When a visitor leaves, they put the glowstick back in the bucket.
hm okay
i dont think network situations like that will matter for my use case then, since the pool is all just tiles of a board that will stay active for the entire duration of the game and will only move up and down and change materials
im essentially just using it as an object array
Makes sense, in my case I am using mine to keep tabs on each player and since there is a lot of join/leaves, I want to avoid creating/removing objects as it can be costly. Leaving objects be and managing it manually can be a lot of work to network.
My player programs will be enumerated constantly and interviewed for values in some variables, so I am dishing it out as well and testing to find the best and efficient implementation.
mhm, thats fair
like im only using the pool so i can drag and drop all the tiles at once into it
because i cant with the array for some reason
so the pool just exists to instantly be written into an array lol
might be a bug or smthn but for right now this is a pretty easy fix (that took 2 hours to figure out lol)
Hey it's Unity and Udon lol, I am coming from a freedom of writing enterprise software to a constricted environment here
So I have to find a lot of workarounds, and this channel is the best place for getting solutions, advice, and best practices on writing these scripts.
yeah ive been wearing this channel down a LOT since ive started working on this project lmao
I have a big one coming, I want to recreate the Unreal tournament experience with Capture the flag / deathmatch in VR lol
Maybe even Zombie Tag, a cat n mouse kind of mode where you have to infect everyone within a time limit
Does anyone know if VRCObjectPool cares about me renaming the object.name during runtime?
ooo nice, im trying to recreate an old flash game that went defunct when flash got shut down. before that happened though I archived as much of the game as I could so when i finally got the motivation to make it all the details wouldnt be lost media
me and a few friends passionate abt it almost just straight up bought the rights to the game lol
cant be clogged as everything else works
last lines of script
updatechests = true;
GameObject.Find("test gui").GetComponent<UnityEngine.UI.Text>().text = "d host";
RequestSerialization();
finishchestspawning();
i can see text changing in game and right after it i have requestserialization
and in ondeserialization i have text change too to check if it runs
and it never runs
Anyone have a good idea on how to turn off falling animations for a VRC world. There's a lot of fast locomotion and the way I hobbled together to do it doesn't seem to work
I feel like there's some basic easy way to turn off Falling animations for an entire world but I havent found it
I'm pretty sure the only way to change animations from the world sdk, is to put someone in a VRCStation.
okay that's like where i was at; thank you! - it just breaks sometimes for me
You could force people into a specific avatar that has fall animations disabled as well.
Yeah, VRCStation is really not ideal for that... Wish we had more control over the character controller in general.
Is it possible to set an orthographic camera to a specific size (irrespective of aspect ratio)?
is there some simple way of getting variable from other scrip
@arctic scarab See this one, I am setting the variables in an instance of another script, but you can also just read them.
ok then no
Correct, this one
i dislike drag drop paths
Well you can hardcode the instance and use .Find to get the gameobject holding the script.
Even with GetProgramVariable provided by Udon, you still gotta reference an instance 😛
You could define a script that is like a datasource/database for your variables and just have other scripts reference it to exchange variables and updates..
Need an example?
yes
i have 4 arrays that i need to run function with but ondeserialization seem to be working only in one script
so i want pass these variables to other script and run it there
udonsharp example of course
Where I run my behavior on the parent of ScriptLogic object in the inspector, and the child is "Controllers" that holds instances of my scripts.
Make sure your script variables are public as well, and then attribute the array variables with [HideInInspector] to hide from inspector since you're programmatically defining them.
i have no problem of accessing gameobject that holds script
just how then i access udonbehaviour and its variable
worldcontroller?
My apologies, that is my udon script defined. I will share the two whole files to share the big picture.
i mean i dont know what component to get
if its ready to use or have to make it myself
i have this and i want to toggle bool
Ok, so you will do this gui myGuiScript = this.transform.Find("ScriptLogic").GetComponent<gui>();
Let me put it in my example
ok it work now
Sweet, well here is what I made. Below is your script that will update variables in your other behavior.
And your GUI script
Basically your script is a "Component Type" in terms of Unity just like VRC Player Pickup, etc.
And a bonus, I love FieldChangeCallBack, you can use that to announce or call Serialization when the variable has finished updating in your gui script.
But in your first script, you declare the variable that is your gui script that'll be filled in by .GetComponent<> at Start();
Once that is done, you're free to access methods and variables of your gui script.
Another example where I am referencing an instance of my Role script to see if the player is a member of the role, and set its variable to true. (This is an example mashed together) Lastly your IDE should respect and list your defined variables and method as long as the protection level is set to public for your variables.
so that way i can run functions from other script too
request serialization from other script
Yeah you could just literally have that script be your database and let that one do all the serialization/deserializations itself. But then you need to broadcast a local event to say "Okay, check the database again and see if any variables changed".
Edit: I don't think you need to broadcast, you just compare after updating
im just having all synced variables in other script
Gotcha
i just update them locally and then request serialization
Is there a way to make VCRUrls in the node editor with strings? since it isnt possible in udonsharp
You cannot construct new VRCUrls at runtime (except for the VRCUrlInputField with manual input by the user). Thats by design as a security measure.
but then... i can tell the user what to type in and validate it at runtime... so it doesnt secure anything, does it?
You can tell them. But that doesnt mean they have to listen to you.
This way you cant force someone to visit a dynamic URL.
well that was the idea...
You cannot construct new VRCUrls at runtime, except when a user types into the VRCUrlInputField manually.
Thats by design. Deal with it ¯_(ツ)_/¯
yea i get it.. i found the hardway in ~18hrs
but as long as i can verify... it shoudl still work
Yeah thats possible.
welp i guess thats gonna happen
i moved everything to other script and it still seem to not run
why ondeserialization so broken
public void thing()
{
someint = 5;
RequestSerialization();
}
public override void OnDeserialization()
{
if (someint == 5)
{
do stuff
}
{
i made it as simple as that
and its not working
I'll see what I can do, at work atm
How can I check if the player is already in a trigger?
Also, what's the unity equivalent of "Get all actors of class" from unreal?
if (_localPlayer.isInstanceOwner)
that might be issue
but it shouldnt be because it runs local scripts
and then sends results to everyone else with deserialization
That's request serialization to say hey, please take my changes
Deserialization is "I got your answer, and I'll read your data"
thing runs on isinstanceowner only
but requestserialization should run for everyone
did i wrote it incorrectly
noone is getting answer
if i instead switch host to someone else still only my primary account runs script
so isinstanceowner is clearly thing that blocks path
Can you dm me the whole script?
@arctic scarab This caught my eye, but I remember you said it worked at least once? Are you running your test with multiple clients?
no im running uploaded
Maybe this is the issue: OnDeserialization only fires if data has been received. The one who calls RequestSerialization won't call OnDeserialization because they don't have to receive the data.
So you have to call it yourself.
i saw it does fire multiple times by itself
just int havent got shared across others
possibly all other synced variables havent got synced either
it must be host only thing
Remember that you need to be the owner to send stuff. Also, you need the attribute UdonSynced on your variable.
all variables have this
and i send as owner and both non owner
in both cases my primary account does stuff
If you have both of these and RequestSerialization, then everyone else's OnDeserialization will be called.
and other dont
Something else must be going on then.
We need more info than just that.
and everything up to this function does run
for host only because host supposed to pass info to others
Is it possible for the object to change owner? Try setting the owner before sending the id.
Otherwise we'd need to see more of the code. Difficult to know what's wrong without seeing the full picture.
is it possible that just this function not work because synced variables are too big and every other networking will work
have like 5 arrays with 100 entrys each
there function starts
if its not network issue than isinstanceowner is what blocks sending it to others
isnt there some other function that forces synced variables into clients and runs script
I'm confused why you are using isInstanceOwner in the first place. Whoever created the instance might not even be in the there and your code won't run at all.
just alternate for host only thing
because script generates many of random numbers and want only host to do it
then send results to client
As I said, the instance owner might not even be present.
For example, if you Build and Test, then there is no instance owner.
Use the ownership of the object for these things.
If someone leaves, it will always go to someone else, so you will always have someone executing those methods.
so i will search for host thing
Use else if instead of if
but lets fix thing not sending first
nono
it guarantes all will run
in case of int being something already
so it changes during ondeserialization?
damn everyone gives me fixes for code i dont need fixed
i need fix networking only that
lol sorry I literally just opened the channel and it was the first thing I saw
At least here you can just put using UnityEngine.UI; on the first few lines so you don't have to type UnityEngine.UI.Text every time but can just type Text
again
As I said, we need the full context. And I'd definitely replace isInstanceOwner as it might as well be one of the issues.
yeah isinstanceowner is something different than the object owner
you probably meant Networking.IsOwner(gameObject) if you're not setting owner in your chestsspawnsynced method
yeah exactly
replace isinstanceowner with Networking.IsOwner(gameObject)
also idk what you're doing in those for loops but if you're making any changes to anything else than synced variables you should do it in OnDeserialization
im making variables there
and bottom variables are changes
passing from first script to another
to update synced variable
well just make sure you're actually checking/setting object ownership
instance owner has nothing to do with networking
im not changing object owner just ensuring only one person runs local script
yes but if you want to serialize they must be object owner
not instance owner
there's also 1 object owner per object
so Networking.IsOwner(gameObject)
so am i supposed to make every remote player owner of this script on deserialize
to ensure every player be able to run
no
you run the script in ondeserialization
and the object owner just changed synced variables
so i add owner change before variable change
@arctic scarab I got off work so I'm going to mash together a network demo in u#
If my pc can handle multiple instances of the game, we will see lol
Any idea what this error means?
For some reason CyanEmu defaults to pausing it as well
Oh, I just needed to set up the layers and collision matrix
rip my potamus
Question, is there an event or method that fires when VRCObjectPool returns a object?
I.e OnPreVRCObjectPoolReturn();
// Cleanup the variables of my player behavior in the object to be returned.
OnPreVRCObjectPoolReturn() {
this.playerInventory = null;
this.playerRank = null;
SendCustomEvent("RecountPlayers");
}
I'd like to patch the Teleport Player script and change from Interact to player collision in the udon examples: https://github.com/vrchat-community/UdonSharp/blob/master/Docs/Source/Examples.md
I found this graph example and thought I could simply override it
public override void OnPlayerTriggerEnter() {
but it seems that method doesn't exist
does anyone have any ideas?
so has anyone found solution
why cant i name this?
Define a string variable/constant and attach
... ive been doing this for a hour can you explain that to the more simple minded
lol
I'm not sure what that is either. When I've used network event nodes like this, I've created a custom event node (you can just search for it) and then basically use that where you would use the interact node if it wasn't a networked graph. Whatever you name the custom even node, you'll be able to choose that in the eventname once it's created.
yeah im trying to make a death star with doors that can be toggled for everyone and no youtube video shows me how
so im really confused
Are you trying to move them with Udon? Activate an animation? This script will turn something off and on but it won't be synced for anyone that joins later. If you want to do that, it gets a bit more complicated. I'd recommend these videos to learn that stuff. https://www.youtube.com/c/PlayerBush001
Heyo, Bush here.
Learning unity and VRChat together is hard, especially when there aren't enough videos to get you started. Hopefully I can help with that! I hope to make tutorials that are fast and to the point. Ones that you can look over without have to resort to 2x speed, but also contain everything a newcomer would need, should they be wil...
yes
ty
Moving them with a script is different from triggering an animation. You can do either, it's just a matter of preference. I'm not sure if animations can be synced for late joiners, though I know there's a prefab for that.
I think you can pull the current playtime of the anim clip and use that sync
Good to know, I think the one in the prefabs database does something with the system clock
Idk if it's exposed, but on the joiner, check if the clip is playing then sync the time and have it play right from that point, can't guarantee it'll be sync'd to the exact second.
anim.GetCurrentAnimatorStateInfo(0).length)
I don't know much about Udonsharp but I'll try to keep that in mind if I need to do that.
Is vrcinstantiate broken?
I'm trying to create a clone of a prefab per-player with its own udon behavior on it to handle movement and components; for reasons, I'd prefer to use a local object with unsynced variables, rather than go through the mess of syncing variables and component states across the network, for consistency, simplicity, and speed (immersion).
However, it's only instantiating a single copy when triggered by OnPlayerJoin. It doesn't seem to work with additional players beyond whoever is first in line. Instantiate is supposed to make a copy of an object, yes? So why is it stopping at one?
Likewise, when I looked at object pool, it seems, IDK, counterintuitive? If I'm understanding correctly, I would have to prefill the pool with duplicate prefabs equal to the max # of players, handle spawning them and returning them to the pool on leave, and ownership, vs. just instantiating a dynamic prefab and setting owner, destroy on leave.
The objects are meant to be local only, but their udon behavior makes each instance follow their respective player.
Am I missing something?
can somone teach me how to do synced toggles
I look at VRCObjectPool as a miracle atm, since you're serializing your objects/prefabs before runtime, it's very performant and no need to instantiate. I am doing this to hold data for each player.
But doesn't this mean I have to add duplicates of the same prefab to the pool if I want to have enough for each player? Or am I misunderstanding pools.
Instantiation was, from my perspective, dynamic, only creating objects at runtime.
Instantiation, yes but costly to CPU.
Object pool, serialized before runtime and all objects are ready to go and brought to an active state when you call TryToSpawn(), which is performant AND VRChat sync's the state of your pooled objects for you.
Hmmm. To give a little more clarity then, to make sure it's what I need, I have an invisible object with a rigidbody trigger & audio source on it, that when it intersects a particular ground collider, it plays footstep sounds whenever the player moves.
The point is that you can hear other players' footsteps, as well as your own, so it needs to spawn a local copy of the prefab per active player, and then follow the assigned player until leave, when it is destroyed.
Instantiate is only working for the primary player (instance owner) despite being called with onPlayerJoin.
Would ObjectPool be suitable for this?
Your solution should work too. There is probably some kind of issue with your code. Common mistake would be to let all instantiated objects follow the local player.
Nope. OnPlayerJoin takes the returned VRCPlayerApi object, and Sets Owner on the instantiated object to said player.
Then the instantiated object's udon behavior gets the owner, and moves it based on the position of said owner.
So unless OnPlayerJoin is returning the wrong player, or Set Owner isn't properly setting the owner, it should work.
I'd like to see code of that (especially the movement logic). I'm fairly confident your approach should work.
Is it possible there's a race condition, "of sorts"? Where when I grab the owner it hasn't yet been set?
This is the logic for instantiation.
Yeah, you can't set ownership on instantiated objects.
Because Instantiate just spawns an object inside the engine. That method is not hooked up to any networking.
I'm sure VRChat could make a specialized instantiate for that use case, but they have not done that.
You honestly don't even need ownership to do footsteps. It's sufficient to just set the owner variable directly and only call update if owner is not null.
Hello when I press y and go to worlds and try to type in the search box the keyboard won’t show up I play on quest and I just started a few minutes ago
Heh. I thought about doing that, but Set Owner seemed easier at the time. I guess I should have stuck with that.
It worked! Thanks!
udon seems to be erroring out bad, this is the game object I'm using fo rit
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
public class GameObject : UdonSharpBehaviour
{
void Start()
{
}
}
and the script
I don't know a lot about Udonsharp but I'm pretty sure that script does nothing.
It tells the game object to do nothing when a player enters the instance.
Right, I dont need it to do anything
Setup instructions just told me to make that
That is very strange but if you say so. I'm not sure how to debug something that doesn't do anything but I| would assume it wouldn't cause problems. Are you sure the errors are with the script itself?
The game object is throwing errors so I think so
I'd post a screencap of at least some of the errors. You do have UdonSharp installed, right? I think there would be an error on the component itself if you didn't.
You shouldn't use the name "GameObject". That is a name that unity already uses.
You can't use GameObject because Unity already implements that
Ah, that makes sense.
For the script? Or the object itself
Or both
The script behavior specifically
Yeah, the scene object name doesn't matter as much.
I tried changing the script name already and reloading
I can reload the whole project
still nothin
Make sure your file name matches your new class name, and also the udonsharp asset file matches the same.
You still have your "GameObject" script in there
where
ah I found it where it most definitely should not have been
I can publish now yay
Thank you
Ususally you use a player object pool when you want a networked object for every player https://github.com/CyanLaser/CyanPlayerObjectPool
i can force network event but then its not guaranted that variables will sync
can i send network event with parameters
i need some way of "guaranted variable send to other players right now"
That's exactly what manual sync is
Everything is best effort not guaranteed
but I have not had any issues this far, of it dropping updates with manual sync. Automatic will keep resending the data so it might drop the first package but it will be synced after a bit
theres no place for error
every variable synced
then it requests serialization
and before changing variables it also ensures variables will change by claiming ownership
do i have to sync whole local function as well
or what
i just want do sendcustomnetworkevent to everybody now but how i send it with variables
is it possible that because of variables are long arrays new ondeserialization starts before variables finish syncing and that makes them reset?
i know that
just the thing they never get synced
probably they too big
Are you sure you're getting ownership of the right gameObject?
why are you using GameObject.Find if you got the reference to the udonbehaviour on that gameObject?
Just use s.gameObject to be sure that you grab ownership of the gameobject of the script you're trying to change values in
its the correct one
because when host runs it it does work for him just not others
and i used that for other scripts
how i sync variables manually
or pass network function with synced variable but without defining them
aaand can i pick which variables are manual and which automatic
or i have make separate files for each
Each gameObject has its fixed sync type
So a gameobject can either be manual or automatic sync or no sync
i think i have to make one with manual as automatic does not work
or network function with variables if that exist
yes it states only small ones work with auto
how i update manual
also whats tween
i updated manually and even then its not working
is 4 arrays of 100 variables each too much to vrchat to never sync it up
Are those ints? Then it should be fine according to their specs: https://docs.vrchat.com/docs/network-details
Try not to sync everything; consider what you can determine from the minimal amount of information shared. For example: if an object will move on a fixed or predictable path, then its position may not need to be synchronized and instead its initial location and velocity may be sufficient. If there e...
3 ints and 1 strings
How long are those strings on average?
5 symbols
and i think ondeserialization never actually runs from that certain function
Check OnPostSerialization, it can show if stuff is being send and the byte count. Haven't used it myself but seems useful in your case.
But in general, you shouldn't need to send 100 strings.
yes i do need
I disagree.
stores all generator info
There are usually ways to send it more efficiently.
but i expected it to run with delay
but it never runs
so if i run requestserialization and ondeserialization never runs only explaintation is too large variables?
hmm from what i see even after removing synced variables deserialization not running
Oh god how am I going to sync user roles
im using it for find() lol
guess im just gonna cut variables into ints and leave pre defined text in finds
hoever
ints starting with 0 automatically cut out this 0
can i fix it
Any reason why as soon as I add a UdonBehaviorArray it breaks the graph?
I even set it to public thinking that would fix it but didn't...
Does anyone know what it means if an Udon Sharp script does get called when testing in Unity but does not get called when Testing & Building in VRChat?
Does anyone know how to check if in VRChat your Udon Sharp scripts are being loaded?
You cant do udon behaviour arrays. If you want to have one as an array, the best method I've found is to instead use a gameobject array, and then use gameobject, (type) get component (type udon behaviour)
Do Udon Sharp behaviours not work on prefabs?
I put a script on a cube and then on my prefab, it worked on the cube but not the prefab GameObject?
They do. Vrchat can be a little weird with prefabs though, sometimes reseting their values at runtime.
Do you know how to make sure that an Udon Sharp script does work on a prefab?
Luck
I can get it to work when testing in Unity, but there's no indication why it doesn't work in VRChat when I build it
As far as I've seen it's really random
My audio source is very quiet when spatialization is enabled. It doesn't seem to respond to changes in Gain or anything. What's up with that?
So do I have to put the script individually on every gameObject of the same prefab?
I can't put it on the prefab?
Are you sure it's the prefab though? Try unpacking the prefab and see if it runs then
I am unsure what unpacking it refers to
oh?
In the Hierarchy, right click the object and click 'unpack prefab'
I don't seem to have that option
Yea.. It does that.
Is the object blue? And thus, a prefab
Spatialization makes an object quieter the further away you are, based of a curve. When you hit the dropdown menu, you can increase the far distance, which can sometimes help, but also you can tell it to use the unity audiosources curve instead, allowing for you to fine tune its fall off. Also, the gain value only goes from 0-10, so any values above that won't do anything
I'm trying to turn off isKinematic on the gameObject's rigidbody when it's picked up
It works on a cube when I test in Unity and when I test in VRChat
It works on my prefab gameObject when I test in Unity but not when I test in VRChat
I feel like the script should work...
It's not shown in this image, but is this a prefab inside another prefab?
Yes
Then you will have to unpack the overlording prefab ^^
Okay, I just put in another prefab by itself that I will unpack for testing purposes
Good call
Okay, I just unpacked it, not sure what that does though
Makes it so that any prefab changes won't effect it, as its no longer part of that prefab
ah
Hi there. I want to make a PVP game, and I need to add a combat system, does anyone know how to set up a basic one in udon?
I notice the Unity Audio Source volume is also capped at the default. Am I to understand I can't change the how loud it sounds?!
Unfortunately unpacking the prefab didn't help
Just noticed your username. I've been following your tutorials very heavily these past few days/weeks. Thanks so much!
Unfortunately, the combat system is depreciated, isn't really functional, and can be removed at any point. The only use it has now is to set hit points to zero to get a ragdoll effect
But it does work when testing in Unity with the VRChat Client Simulator
There could be many things going on here, all of them not obvious. Sorry, but your going to need to do a bunch more testing to find the problem :/
Just a simple one, all I need Is make a player respawn when touching a particle
Is that possible with udon?
I'm not really sure what to test...
Because it doesn't output anything to the log when I test it in VRChat
It does output to the log when I test in the VRChat Client Simulator, but it already does work there
Yes but... The only method I can think of is having an object follow you to be your collider (see my object follower tutorial), but if you want to use this for some kinda combat system, you will need to give each and every player a collider that other players can hit, to tell those other players that they have been hit with your particle
As the lag would be too much if they did it on their side
You just need to broad test when something does work, and when something doesn't. Try adding your working cube to be in the same place in the Hierarchy, try taking your object out of the prefab location completely and see if the script works then. Try different objects to see when it fails and works. There is something not working somewhere, and you need to find when it works and when it doesn't. Then you will find your problem
okay, I wish I could test it in the VRChat Client Simulator because it takes much longer to troubleshoot through VRChat
Glad your finding them helpful ^^
Mmm and would It work if I make a teleport button for example, but with a collider detection instead of Interacting?
And using the particle as variable
I just wish this one were longer by an extra 2 minutes. All I want is a global, spatialized audio source that isn't super quiet. https://www.youtube.com/watch?v=cQ3hWKY-NiA&t=73s
A simple tutorial, covering how to make a button that plays a sound in udon. I've seen a couple of post asking about how to play a sound in udon, so hopefully this will give a good foothold to bounce off from.
If there is anything I missed, please leave a comment bellow!
Amplifying a sound with something like audacity isnt too hard, and it's better to make all your sound correct before changing them in unity. Given you said it's better without spatialization, your fall off curves could be more to blame
I'll just do that then. I'm new to this whole thing, and it seems like, more often than not, when I need to open something up in a 3rd party program it's because I don't know how to do it inside Unity.
it sounds like you just want to use playerApi, respawn, but the problem is getting that playerApi. there is an event onParticleCollision, but that won't pickup a playerApi, only objects
does anyone know why my cameras are picking up phone cameras and controllers in vrc even though ive turnt of ui?
double check they aren't on 'ui menu' or one of the reserve layers
reserve layers?
layers 'reserved 2', 'reserved 3', 'reserved 4'
I found out that if I have VRC Object Sync on a gameObject it does not let me change the isKinematic attribute on the gameObject's rigidbody in Udon Sharp, does anyone know how to do this properly while having the VRC Object Sync component on the gameObject?
It does work in the VRChat Client Simulator, but not in VRChat itself
That's what I had assumed, and why I wasn't, nor am not, using ObjectPool.
The objects are handled entirely locally, un-networked, despite being spawned for each player, as it'd make no sense to me to be constantly syncing the position and play status of every instance of the object, and risk de-sync and lag, when I can just handle movement and status locally.
I was just misunderstanding the purpose of "ownership" is all. More or less tried taking a shortcut that didn't work. :P
Is there a way to sync a gameObject with something like VRC Object Sync when the gameObject gets manipulated in some way with an Udon Sharp script?
Is this what you are looking for?
Haven't used that in a while so not sure how exactly it works.
I should put that in my gameObject's udon sharp script instead of having a VRC Object Sync component?
You put VRCObjectSyncon on your game object and then reference it in the script that you are doing stuff on.
Oh okay
Do you know where documentation for something like that might be?
It seems unintuitively arbitrary to do it like that to sync it and it would be completely incompatible with a nonsynced version
but I'll definitley retry with a method like that and see how it goes, so thank you
Thank you!
This doc covers Networking Components, Properties and Events you can use in your Udon Programs. Special properties you can get from Networking: IsClogged - returns true if there is too much data trying to get out. You can use this to hold off some operations or adjust your logic. IsInstanceOwner - r...
I think this is for Udon, do you know if there is one for Udon Sharp?
Why would that be different? The API is the same.
Oh, okay
https://udonsharp.docs.vrchat.com/vrchat-api#vrcobjectsync this is U# spesific
Thank you!!!
I have a question about variables and syncing on player join;
In my world, there's a music selection tool, as well as the ability to turn music off, which is controlled all by the variable audioIndex [int]; This variable is manually synced, as it's the only variable that requires synchronization, and is only ever manually changed, with the rest of the logic and variables being handled client-side.
When multiple players are in the room, and the music is changed, it correctly changes for other players. However, for late joiners, it is playing the audio for the default value of audioIndex.
It currently changes the music on audioIndex Change, and the startup logic runs On Enable and checks the value of audioIndex, setting the music appropriately and initiating play, if valid. But it seems to either not be syncing the variable at join, or, the On Enable block is firing before the variable has been synchronized.
Is this the wrong way to go about it? I don't want the startup logic firing every time the variable is synchronized. But it seems like variables might not be synced immediately? Or have I misunderstood something.
Nevermind; Setting the script to continuous (and using On Player Join instead) fixed it. (Manual variables are purportedly suppose to sync for late joiners, but it's whatever I guess).
In that case, it would collide with the object that follows the player right?
yea, and having a an object follow it's owner, would allow you to fire a networked event to that owner, telling them they were hit
The sync.setKinematic did it!
I wouldn't have guessed, I had been doing rigidbody.isKinematic = false
for pc players, is there a way to have an object be both interactable and pickup-able without having to do both at the same time like a gun?
What's the best way to copy + paste numerous materials onto an object or material array?
how can i check if the player is inside a trigger that belongs to the same gameobject before executing OnPlayerTriggerExit/Enter?
I have some triggers placed like this, the parent gameobject fades area music in/out when you enter/exit them
But right now, when you move from one trigger inside the area to another trigger, the enter/exit functions execute again.
What is the best way in Udon to get something like OnRespawn for an object?
I see there is an OnPlayerRespawn method and a VRCObjectSync.Respawn() method but I want to either override the Respawn method on VRCObjectSync or detect if an object was respawned like you can with OnPlayerRespawn
an OnTeleport event is probably what i need
or i would need to override the TeleportTo method on VRCObjectSync, but I don't know how to do that from an UdonBehaviour
Is there a way to add a delay to a For node?
like have it wait 2 frames before going to the next object in the array
If there are multiple objects that affect 1 Score, and anyone can trigger those object that affect this score, how can I treat the relation? Send VRC_Direct actions to Sned All by the Owner, and change the Score locally?
More into it: When interacting with this square, I want it to sum 1 to the team Blue. I'm putting the variable in the Team Blue global vairiable object.
I don't believe that's possible. Since you are firing the respawn event anyway, that means you can just send a networked event at the same time if you want to do more stuff on every client.
You can't in udon. You have to use a timer in update or a repeating delayed event.
So when you start the process, you set an int to 0 and then increase it every cycle by hand. Take out the value with that index and repeat.
What do you mean by "VRC_Direct"? Afaik, that's not an udon component.
It sounds like you are talking about manual sync? In that case you can just set the owner before you set the variable and then RequestSerialization.
I'm unable to get a string from an udonbehaviour program into another udonbehavior program. I made the variable public in another udonscript where I set it when I interact with a cube and used the getprogrambehavior node in the UI with the text from udon examples
From what I can see, your setup should work.
Your text field should display "test" after you Interact with the first object and then walk into the second object. You might want to make sure that your inspector is setup correctly. You need to drag in the correct UdonBehaviour, for example.
Are there no errors when running the code?
the Is Valid function returns false . I also have set a onplayertriggerexist with an exit message, when I enter the trigger the text looks empty (before using IsValid) and when I exit I can see the text for the exit event
Have you tried what I posted above? If it's false, that could mean that you selected the wrong UdonBehaviour in the inspector or you miswrote "text".
The problem is I'm not sending the teleport event, it automatically happens when an object is thrown off the world
That makes sense. Sadly, I don't think there is any "on VRCObjectSync respawn" events.
You could handle the auto respawn yourself. The scene descriptor has a height, which you could turn down. And then just detect it yourself.
I can't drag the UdonBeaviour variable into the inspector tab it is permanently set as self and won't let to drag in. Here are the inspectors of both scrips and also the inspector for the object in the scene
Do you have to set it to public or something? I don't use graph so I'm not sure why you would be able to.
Btw, you don't drag the "variable" you drag in the other script that you created in there.
I set them all to public . Also I tried to drag a script but won't let me either
That is the wrong thing. References like that are done solely in the scene.
So drag in the gameobject/component instead.
thank you so much 😁
You have to drag them into the "materials" text, not the individual field.
What text are you referring to? I just tried and it's not working for me.
This should be working:
I wish!
Hmm, this might be a udon graph issue then. I'll try it out myself.
❤️ ❤️ ❤️ ❤️ ❤️
Yep, it doesn't work for Udon Graph. U# it works fine.
What to do?
Not much, unless you want to dive into SDK code. You could try making a canny ticket, but I feel like there might be one already.
You can also just port that script into U#.
Good to know, thanks. Is it possible to do so automatically?
Not that I'm aware of.
Got it. Thanks.
Hello, there is any guide on how to make a simple combat system with udon?
What do I do when the wheel where you have options, emoji, and expression doesn't work at all?
this is more of a question for #user-support-old
Ok
nope. the current best is toly's combat system prefab, but it's not plug and play and is kinda complicated. think it does have a basic premade gun though (https://github.com/Toly65/UdonCombatSystem)
guess i'll have to work with it, I saw it has some guns, but I wanted some tutorial on how to make something melee
anyway thanks
tried to use the premade gun but in testing it does not do any damage
guess i'm missing something
do we still need to use dynamic bones in worlds?
Yeah, no physbones yet.
is there a way I can have a text display the players name who interacted with a object?
using udon sharp
hello, so i made a simple open-close door system with udon. I'm using custom event for it and SendEventOnInteract from udon examples to send the event.
it worked well until one time i tested my world and the graph just automatically changed by itself
when i checked, apparently, UdonBehavior - SendCustomEvent node got removed
I don't know and I don't understand why
i tried to re-add the node to fix the graph but whenever i connect target node as the instance, SendCustomEvent node will always get removed
it keeps giving me this message
removed node VRCUdonCommonInterfacesIUdonEventReceiver.__SendCustomEvent__SystemString__SystemVoid
it also says
Error Loading Node VRCUdonCommonInterfacesIUdonEventReceiver.__SendCustomEvent__SystemString__SystemVoid : Object reference not set to an instance of an object
I'd be really grateful if anyone can help, thanks
Is it possible to remove the object interact outline?
Anyone know how to use PlayerApi, SetAvatarAudioCustomCurve? Dunno if I'm even using properly, but I would assume it's meant to have an input as to what you want the curve to be, but it doesn't have an input for that, so I'm a little confused. Is it even properly implemented yet? Was it an old abandoned feature like the combat system?
I mean, it looks like it lines up with the VRC Spatial Audio Source component, but do we even have an audioSource that you would normally have along side this component, if it was on a normal object?
Hello! I'm new to VR in general and was curious about changing avatars to custom ones
this is not the right channel for these types of questions, check the avatar channels if you're curious about avatars
Hey guys, I'm getting an error when trying to access the Length property of an array in UdonSharp
code?
it's saying that your array doesn't exist
the Debug.Log
It's working now, apparently it wasn't compiling before I hit Play
thanks for the help
How have people worked around the limitation of the string[] not able to be sync'd? If someone joins a team I am needing to make sure that I tell the rest of the players that this person is now on red.
you can definitely sync string arrays
just needs to be a manual synced udonbehaviour
@dawn forge
Some structs like Vectors can't be mutated in either Udon or Udon# (I forget which one is the limiter) iirc
oh thx now it worked when I used the matrix constructor
Having trouble getting a sprite to have a billboard effect, basically have it face the player's position. In normal unity it's just one line of code
transform.LookAt(Camera.main.transform.position, -Vector3.up);
But having never used Udon before I can find the transform.LookAt function but can't get it to play nice with the VRCPlayerApi nodes I can find
How can I make this happen? Ahaha.
Hello guys, fresh udon user here. I have a question. I want to make a script that plays a song and change the lights color upon interacting with an object. The sounds plays alright
but the light doesn't change, am i missing something here?
The logic looks good, so I have three questions:
- Can you confirm that the light references a valid light in the inspector?
- Can you try it again but set the color of your light to have full alpha (looks like it's at 0)?
- Do you get any errors when testing this?
Yeah, you're not allowed to directly access the user's transform for player security. You can take a look at the Switcher prefab in the UdonExampleScene which orients itself to a player's Head Tracker for the same effect.
I'm at my wits' end. Why doesn't this work?
I don't think that class is exposed to Udon
if you're targeting the UnityEngine.InputManager and not your own class
Oh dear. I'm just trying to stop things from glowing blue when I interact with them. 😅
That's one of the core UX features of VRChat so players know what they can interact with.
Can it not be adjusted? If not, what does EnableObjectHighlight do?
I tried targeting the VRC.SDKBase.InputManager class, but no dice.
Right, those are not exposed to Udon.
Nor InputManager, nor VRC.SDKBase.InputManager? Unless those are the same.
Oh my bad - yes, you shouhld be able to use EnableObjectHighlight, passing it a boolean and a GameObject or Renderer to control.
That's excellent news! What am I missing?? Thanks. 🙂
The problem is that you're passing the type "GameObject" instead of the actual gameObject whose highlight you want to control.
if you want to control the highlight of the GameObject on which this component is sitting, just turn that capital G into a lowercase g.
Then you'll be referring to the current UdonSharpBehaviour's gameObject property instead of the GameObject class.
If you want to make it so the interact highlight never shows up you would have to run that function on PostLateUpdate() rather than Start()
You're a life saver! Thanks so much. I would never have guessed.
if I have a pickup object that a player is holding, when they "die", they get teleported to a separate room. How can I make the player drop the pickup just before they get teleported so the pickup object doesnt follow the player (with udonsharp)?
I tried teleporting an empty gameobject to the pickup's location, teleporting the player, then teleporting the pickup to that empty gameobject, but it didnt seem to work- the player was still holding it in the death room. I also tried disabling the collider to the object in hopes it would just drop but its still in hand, just cant be re-picked up.
You can call Drop on the pickup object to make the localplayer drop it
how do I call drop?
(object).Drop();?
VRCPickup.Drop
sooo how i detect pressing the pad stick buttons
someone can help me with the video player? In my project for some reason (I created it with the companion) I'm missing VRC Url Input Field
Does anyone know if the udon kart system works with sacc flight?
no idea but am about to see if it does because that sounds fun
Please do lol. I'm making Jurassic Park and I want to have drivable Jeeps and flyable helicopters
I have gotten so distracted, It works with Kirby flight and with Puppet's flight
I think itll work with sacc,
how to detect pad analog button press
anyone know what makes this local (screenshot pls)
It doesn't have udon synced variable so that makes it local
where do i put it
oh
wait
im dumb
someone know how to take the number of the players inside a box collider trigger?
is it possible to make a player be able to walk around a planet/spherical world
ive seen one world that had the player walk around the planet and i wanna figure out how that is done
Use a VRC station and I believe you can activate their locomotion walk animation
how would i get crouching and prone to work
if i trun off sit i can do emotes and stuff but i cant crouch or prone
You'll need the station to override your locomotion controller https://docs.vrchat.com/docs/vrc_station
See Animation controller parameter
Used to allow users to sit down. Example can be found in the SDK as VRCChair. This component can also be used on avatars to create seats on avatars! This component acts a bit differently in VRCSDK2 and VRCSDK3. We support SDK2 and SDK3 stations that have animations to drive either SDK2 or SDK3-based...
And on your controller you implement the crouch/prone animations
if the avatar has a costom animation controller can i grab it ant put it on the station
so is there a way for the station to grab the players locomotion controller then
for the moment would it basically be making a stranded unity player controller but binding inputs to VRC player inputs
you can't use avatars animations but can change avatars parameters. import from Avatars 3.0 sdk 2 dlls - VRCSDK3A(-Editor).dll to your project, to be able to use Avatar Parameter Driver
also https://vrclibrary.com/wiki/books/repositioning-remote-players/chapter/wall-walking-example might be related to your sphere-world question
is therw a way to also prevent the station locking the players yaw rotation
Add a constraint
like can only rotate 90 degress left or right
can i disable that
or do i make the station rotate on its yaw when the player camera moves
try to use station's player mobility as Immobilize for vehicles and detect player's head/mouse rotation and with that rotate the chair 
how do u disable players rotation on the yaw
how i detect analog button press
The player's transform is part of their avatar and persists between worlds, so it is not allowed to be accessed by Udon, which is world-specific.
Yes, the same kind of Transform.
if udon could access it, it could just destroy the object and you no longer have a player
that kind of security
it is perfectly valid to have access to destroy for objects that are not protected
This isn't #udon-arguments 😛
We protect the player's transform to stop all sorts of attack vectors that people could take.
there are plenty of functions available for both getting and setting properties of the player, such as position, velocity, name, etc. Those functions are exposed as an alternative to accessing the objects directly
Is there a particular problem you're trying to solve, or a feature you'd like to see?
could you be more specific?
there's definitely room to add more things but it wouldn't ever be done by just giving you a reference to the transform
You're welcome to do so on our Canny!
Does anyone know the basics of how to override the user camera?
So i can set up a system so the DJ can overide their camera and toggle their stream's view between different predefined positons in the world
That's right, you've just described how security works in Udon. We have to wrap everything to allow safe access.
properties that exist on the object, like transform set position and transform get position, those have clear getters and setters sure. But other functions that take a reference to the transform, like destroy, are not clear-cut as that. So you would need to build a list of "this function is not allowed on this object but it is allowed on this other object" and that's just a huge mess
You can make a screenspace Canvas with a RenderTexture, but please don't do that on Desktop (makes it impossible to see what you're doing). The VRChat Obstacle Course Demo Project does that for VR Users: https://github.com/vrchat/VRChat-Obstacle-Jam
because once you have the reference to the object, you can pass it into anything. Udon security works by making that reference null. If it worked by allowing sometimes but not other times there would be all kinds of complicated interactions and it would be impossible to catch everything
It would be VR only since they cant get their camera out on desktop to use it anyway I guess.
I've also seen a neat approach where someone made an object you could put your camera inside. The object has a shader that writes the rendertexture to the camera. But I'm afraid I don't have a demo for that one.
Yea that was the one I think i've seen before, move you camera into a box that has the render texture on it and it overwrites it.
Yeah, if you do Gameobject.Find or something like physics.overlapsphere you can get protected objects, but before udon can do anything with them they will be overridden to null. That's the whole thing about udon security
I don't know if it's exactly the wrapper method that does it but it's some point in the process before it gets back to udon, yes
yeah, again, there's definitely room to create new wrappers for specific things like that but you're never going to get the transforms themselves
well yes, that's pretty much exactly how trackingdata works
trackingdata is a class that contains a copy of all the information of the transform so that you can access it freely
how is that not what you just suggested?
yeah, I'm not saying trackingdata does what you're wanting. I'm saying that the idea of putting data into an unprotected class has already been done for the case of trackingdata
so it is not a stretch to apply that same concept to things other than trackingdata
what you are suggesting is playertransform would be a class containing a vector3 and a quaternion of the transform you wanted to get, is it not?
ah, so it would allow something like playertransform.getchild to navigate the hierarchy?
yeah that's a good idea. You should put it on canny
could definitely apply those same ideas to trackingdata though. I'd love to have access to stuff like transformpoint and inversetransformpoint, as if it was a transform
I’m a new up and coming streamer and YouTuber and I was wondering if it aloud to try and recruit people to be apart of my skit/video for YouTube.
It’s going to k be on vr chat and was going to have roles for some people while other people will just go with the flow and try and make it funny and enjoyable
#rules #10. This channel is for asking questions related to UDON development.
This discord isn't the place to advertise or solicit.
Regardless, good luck with your endeavors.
Listen I’m so sorry I got redirected to this channel by another member. I was just following where they told me to go
Lol don't worry about it. Shit happens. Just letting ya know. Wish ya the best regardless
yep
why is it that if i have a station objects thats rotation isnt 0,0,0 then as soon as the player sits in it they spaz out
ive even set it to freeze the velocity every physics tick and the player still gose flying away
Are there any thing i can do to improve object syncing accuracy?
I have a deck of cards, player 1 throws a card on the table, its sitting perfectly like this
on player two it sometimes settles differently, like these ones partly inside the table
the table surface is a flat plane, you can ignore how the mesh looks
does changing the physics resolving accuracy or sleep settings in the project settings affect that?
Is that at the same angle, player 1 and 2 in the same spot?
player 2 is a little to the right of player one, but they're laying flat for player 1 (I can walk round them and see that) where as on 2 you can see part of them clipping into the table at an angle
And it happens on every attempt you put the cards down? Is this part of the object pool or vrc object sync? But overall you should just rigidbody with x plane?
Does anyone know why adding an Udon Behavior to a station or an object containing a station in its hierarchy would completely disable the station?
Trying to make a wheelchair in my world, but the station refuses to work unless I remove the udon behavior script from it.
Seems to defeat the purpose of OnStationEntered and such...
Do I need to make a custom behavior using the Interact event to seat the player? And how would I go about it?
Edit: Weirdly it seems to be working when I respond to the interact event via udon. Even more amusing, the station controller seems to override the help text to say "Sit".
Different question: When moving an object via translate, how do you prevent it from moving beyond the boundary of your world?
As it stands, i have a wheelchair with a station and custom udon behavior — It works (mostly), but I can clip through the wall collider into the void.
Is there a better property or function to use to move the chair which acknowledges physics? Or a setting or property I need?
so how complex is it to add menu buttons instead of game objects?
wait...gameobject can't be synced...how then do i create toggles that affect all the players?
well figured that out. nvm
trying to teleport a player in another room, but it get stuck on the first linear wall
that happen on the way
someone know why that happen? it isn't the lower case R, the screen has be done before writing it with the uppercase
i'm a newb at all this but it certainly seems odd that with the function being called teleport it would care about the walls in the linear path...
ye since i got more teleport for more cases and this happen with only one of them
hrm. why does it need their current location as a subvalue of the respawn index?
because it is an array of respawn points
well I can try making it just one and see if it will work
oh do you have like a lookup table "if x and y are this then teleport there, if x and y are that then teleport there instead" type deal?
Try delaying it a frame. I remember reading about an issue like that.
Where are you calling that teleport? In Update? Or somewhere else like OnDeserialization?
in update
What is your method of movement? If it's VRCPickup, then yeah, I've noticed that has a lot of force applied to it and will push stuff into the wall regardless of physics.
it is inside a FixedUpdate 🤔
Did you try delaying it?
nope, looking how I should delay it
Oh, you can simply use SendCustomEventDelayedFrames for that
oh i'll try that
1 delayed frame should be fine
I guess
wow
it really worked
delayed it by 1 frame
and it works fine now
how hard is it to give players movement allowances? i figure i might be able to set an int variable to the allowance and then as they walk around they move through invisible objects which each decrease the variable then when they have run out of movement surround the square they are in with an invisible box?
Depends on your use case. What you are describing sounds like a grid based map. If you don't really need those grids, you can just use VRCPlayerAPI > Immobilize to stop them too.
one of my games i'm making is a life scale clue/cluedo so grids are very much needed. 😛 that immobilize seems useful and less clunky than the invisible box though.
Just occasionally, if you drop the card from a little higher, if you place it down softly its fine.
i do worry that my idea for the system could be easily borked. either accidentally spending too much movement by getting too near the center of a square or by going diagnal to spend half movement.
Just make the trigger smaller than the actual grid cell, so they have to go fully into it for it disappear.
And I do think that enabling colliders is probably better than immobilize, so people can still move around and do stuff. Being stuck would feel more clunky. This is just my opinion though. Game feel is kinda subjective and depends on the details.
that solves the accidentally spending but makes the going diagnal even easier. 😛 i thought initially about using a cross shaped box around the cell they are in preventing them from going to any other cells diagnally then moving the box when they claim the token. but that might be the worst solution for all i know.
any of this also presents the problem at not being able to think "oh that's not where i meant to move" but to fix that i'd basically have to have invisible boxes shaped for EVERY possible roll from EVERY square and then they would have to use a UI to select "done moving"...super cludgy i think.
You can also create 8 collider boxes around the player, then only disable the non-diagonal ones. Is that what you mean by cross shaped maybe?
Also, you could also just create a general bigger box around the 8 colliders so people can't squeeze between the triggers and have to chose one.
This really depends on how you started doing it. You could also not force players into the grids, and give them pickups they can only move to certain grids.
yeah that's basically the kind of idea i had just mine was fewer entities but with mroe complex geometry.
so like they would carry large player pawns with them during their turn putting it down when they are done moving but then could go to another part of the house during someone else's turn kinda thing?
Yeah, that's one way to do.
how can I teleport the player remaining inside a box collider when someone left that box collider?