#udon-general

59 messages · Page 100 of 1

wind atlas
#

The way you want to do it really depends. I did deal with a similar problem at some point and I made an editor script that just collects all colliders with a specific script in the whole scene.

hollow folio
#

Hah, not a terrible idea, just seems odd we have to resort to that

wind atlas
#

Like GameObject.Find is possible.

desert apex
#

oh alright one sec lemme try

broken zodiac
#

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...

broken gale
#

I got it to work. Thanks for the tip! I really was asking the wrong question.

alpine rampart
#

hi im new to unity and im trying to figure out how to toggle between cameras in game

indigo finch
# broken zodiac How would I make a VRCObjectPool loop itself and go back to the first object on ...

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:

indigo finch
alpine rampart
indigo finch
alpine rampart
indigo finch
alpine rampart
indigo finch
alpine rampart
indigo finch
# alpine rampart 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

indigo finch
#

also, the camera changes are networked as well, so everyone should see the changes happen

alpine rampart
#

ok cool

#

if there is ill dm u if thats ok bc i gtg

indigo finch
#

kk

shy osprey
#

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

wicked forum
shy osprey
#

is there one that only sets it 1 axis at a time?

#

or just be able to turn 3 floats into a float3

wicked forum
#

I'm not sure, I haven't used the graph

shy osprey
#

found it, its a vector 3 constructor node

trail palm
#

hte vrchat docs dont really explain it, but what does the "event on enabled" do?

indigo finch
indigo finch
trail palm
shy osprey
#

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

indigo finch
shy osprey
#

ah alright

#

i tried that but i thought it was shift and not ctrl so that makes sense :x

indigo finch
shy osprey
#

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

indigo finch
#

Interesting... wonder why

red tree
#

Can you create own custom name tags in your world. Like for example: Creator,

scarlet lake
#

Is anyone taking avatar commisions?

echo drift
#

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.

indigo finch
fierce barn
ebon dragon
#

How do I disable instance culling for a specific object?

#

I've asked in #shaders aswell but this might be a code thing

grand temple
ebon dragon
#

whatever it is that causes meshes outside the view to stop being rendered

grand temple
#

that would be frustum culling then

ebon dragon
#

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

grand temple
#

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

ebon dragon
#

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

grand temple
#

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

ebon dragon
#

yeah it's gonna be a fine workaround

#

❤️❤️this already kind of saved the project tysm

grand temple
#

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?

ebon dragon
#

I might just make my own little system for randomly distributing objects which is what I have been using the particles for

scarlet lake
#

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

scarlet lake
#

k thanks ill try it

round eagle
#

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()
    {

    }
}```
coarse parrot
round eagle
#

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.

coarse parrot
# round eagle Okok, then I'll have to take the long way around. Thanks!

There is a whitelist https://docs.vrchat.com/docs/whitelisted-world-components
Anything outside of this list will not be loaded

round eagle
manic spire
#

does anyone know how to fix this?

#

not sure how to fix compile errors

grand temple
manic spire
#

it's failing to compile the udon sharp scripts according to the console

grand temple
#

and?

scarlet lake
#

this is the udon code

#

also the location is public

indigo finch
scarlet lake
#

sure

#

below is just the udon and material

indigo finch
#

I wanted to see the udon part...

scarlet lake
#

oh

#

💀

indigo finch
scarlet lake
#

should i just remake it from the screenshot on another block?

indigo finch
#

don't really see how that would help tbh

scarlet lake
#

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

indigo finch
#

don't really know how I can help more though...

scarlet lake
#

k

trail palm
#

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

dawn forge
#

Been searching exposure tree, but any alternatives to ColorUtility.ToHtmlStringRGBA(Color color)?

I need to get the hex value of the color....

brazen epoch
#

if nothing else, could convert the 0-255 values to hex manually

dawn forge
#

Yeah I am tinkering with that right now, I will share if it works.

#

Fingers crossed, doing a test run lol

wind atlas
#

lmao

dawn forge
#

Time for a VRChatOverflow forum if I can't share muh code lol

wind atlas
#

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.

dawn forge
wind atlas
#

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.

dawn forge
#

It's a feature 😄

broken gale
#

Is there a way to make a material or object visible to all cameras but the player?

coarse parrot
candid wedge
#

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

indigo finch
candid wedge
candid wedge
#

ok now i want to add audio to my world how can i do that?

dawn forge
#

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

stark adder
#

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

unborn hornet
#

(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);

unborn hornet
#

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.

stark adder
arctic scarab
#

what wrong in these

dawn forge
scarlet lake
#

how do i set a button to only turn objects off

stark adder
stark adder
arctic scarab
#

disapointment

shy osprey
#

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

tropic canyon
#

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

shy osprey
#

a for node would be good for that, right?

tropic canyon
#

Are you making a chessboard in nodes?

shy osprey
#

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

arctic scarab
#

is everyone able to edit udonsynced variable or only host or object owner

arctic scarab
#

okay time to make ingame console

#

how would i make one

#

so it will have scrolling and all that

scarlet lake
#

anyone know why the spheres i spawned down a ramp dont respawn?

arctic scarab
#

what you do with them

scarlet lake
#

they just use physics to fall off the map

smoky sorrel
#

Hi guys does any one know if the obunga avatar is in the game and if so where to find it?

velvet star
scarlet lake
#

k thanks

arctic scarab
#

can i have multiple ondeserializations in separate files

dawn forge
arctic scarab
scarlet lake
#

also am i able to give them collision?

#

when they dont infinitley fall

arctic scarab
#

i think when you add object sync it should definelly teleport back

scarlet lake
arctic scarab
#

check both

#

but probably no different

scarlet lake
#

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

light bobcat
#

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

arctic scarab
#

dont use sync

ebon dragon
#

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

arctic scarab
#

toggle enable

#

will play for everyone

light bobcat
#

i dont want that

light bobcat
ebon dragon
#

yes! that should be it

light bobcat
#

oh im stupid

#

i had it, i just commented it for some reason

tropic canyon
#

just check player.isLocal

dawn forge
#

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.

velvet star
velvet star
velvet star
slate crescent
#

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

dawn forge
# velvet star If you don't need to sync this data you can have just one object that manages th...

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?

velvet star
#

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.

shy osprey
#

whats the difference between a 'conditional and' node and a 'logical and' node?

boreal tartan
#

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?

wind atlas
wind atlas
#

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.

boreal tartan
shy osprey
#

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

wind atlas
wind atlas
boreal tartan
shy osprey
boreal tartan
wind atlas
wind atlas
shy osprey
#

clientsim?

boreal tartan
#

Way! It works, just changed collider sizes, thank you!!!

wind atlas
wind atlas
ebon dragon
#

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

boreal tartan
wind atlas
wind atlas
shy osprey
wind atlas
shy osprey
#

genuinely just hundreds of these

#

looking it up in this server and its apparently conflicting with the default vrc sdk

wind atlas
#

companion is storing the sdk somewhere else, so no need to import the package anymore

shy osprey
#

would deleting the sdk mean i lose the udon code or will they be fine

boreal tartan
ebon dragon
shy osprey
#

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

dawn forge
velvet star
#

make sure that you check if they are the local player first before getting a new pooled obj

dawn forge
#

Like this? if (Networking.LocalPlayer.IsOwner(playerPoolObject.gameObject) && Networking.LocalPlayer.isLocal) {

shy osprey
#

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?

shy osprey
#

im like ripping hairs out why doesnt it work

#

but this works?!?!?!

#

im just gonna assume the vector3.set nodes are cursed

arctic scarab
#

why ondeserialization not work

dawn forge
shy osprey
#

heres the whole node setup

dawn forge
#

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

dawn forge
shy osprey
#

thanks a ton man!

dawn forge
#

I also saw you using position and localposition. Localposition is set relative to its parent, not the world space. Just a FYI

arctic scarab
#

i have deserialize in 2 scripts

#

in first one all works

#

in other one nothing works

#

i made simple check and it fails

dawn forge
#

These two scripts in same game object?

arctic scarab
#

no

#

two deserializations in two different scripts

#

and thinking it might break stuff

#

as it gets quite laggy then too

shy osprey
lofty loom
#

Is there a way to make VCRUrls in the node editor? since it isnt possible in udonsharp

shy osprey
#

getting this error even though the Get node is set to an instance

dawn forge
#

What index are you passing into Get @shy osprey ?

dawn forge
signal maple
#

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

shy osprey
# shy osprey For node

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

dawn forge
#

@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.

shy osprey
#

its pulling Tiles from a separate script, and it is populated

dawn forge
#

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?

shy osprey
#

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...

▶ Play video
shy osprey
dawn forge
#

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

shy osprey
#

so would it be like this?

tropic canyon
#

Don't think that'll work, as GameObject[] is not a component type

shy osprey
#

then is there another way to get a GameObject[] variable if its in a different script?

tropic canyon
#

Just a UdonBehaviour.GetProgramVariable?

shy osprey
tropic canyon
#

hm that should've just worked

#

I'm not very experienced with nodes.. as they seem too much work to deal with.

shy osprey
#

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

tropic canyon
#

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

shy osprey
tropic canyon
shy osprey
#

would have had to manually put in 100 objects multiple times

shy osprey
tropic canyon
#

oh lock the inspector

#

it has got a small lock on the top right I think

shy osprey
#

ohhhhhhh

#

ty!

tropic canyon
#

that will lock the view at that time and any selection will not make it change

shy osprey
#

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

tropic canyon
#

I thought it'd work.. maybe it's U# only

shy osprey
#

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

shy osprey
#

would that still be accessible in the node graph?

dawn forge
#

If you make your array public and not hidden in inspector.

shy osprey
#

like this?

#

got this error again

dawn forge
#

Yeah it's a U# thing for populating the arrays with drag n drop, didn't work with the graph

shy osprey
#

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?

dawn forge
#

Crafting example

#

Ummm graph... Idk...

#

And U#. I can't complete the graph lol.....

shy osprey
dawn forge
#

It's a defined variable in the graph I dragged and dropped onto

shy osprey
#

ok i figured it out

#

do pools disable all the objects in them by default?

dawn forge
#

Yeah, they start inactive.

shy osprey
#

would just doing a for loop at the start to make them active work?

dawn forge
#

Nope, the pool will assign you an object on a successful spawn via GameObject type.

shy osprey
#

this did work though

#

didnt need to use the trytospawn node at all

dawn forge
#

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.

shy osprey
#

does TryToSpawn just call a random object or does it do all of them at once

dawn forge
#

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.

From https://docs.vrchat.com/docs/network-components

#

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

dawn forge
shy osprey
#

all you can input is the instance of the pool itself

dawn forge
#

Its the objects you referenced in the inspector in the scene.

shy osprey
#

so it does do all of them at once?

dawn forge
#

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.

shy osprey
#

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

dawn forge
#

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.

shy osprey
#

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)

dawn forge
#

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.

shy osprey
#

yeah ive been wearing this channel down a LOT since ive started working on this project lmao

dawn forge
#

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?

shy osprey
#

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

arctic scarab
arctic scarab
#

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

torn shuttle
#

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

wind atlas
torn shuttle
#

okay that's like where i was at; thank you! - it just breaks sometimes for me

wind atlas
#

You could force people into a specific avatar that has fall animations disabled as well.

wind atlas
broken gale
#

Is it possible to set an orthographic camera to a specific size (irrespective of aspect ratio)?

arctic scarab
#

is there some simple way of getting variable from other scrip

dawn forge
arctic scarab
#

ok then no

arctic scarab
#

i dislike drag drop paths

dawn forge
#

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..

arctic scarab
#

find works yes

#

just i want get it using coded path not drag dropping

dawn forge
#

Need an example?

arctic scarab
#

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

dawn forge
#

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.

arctic scarab
#

i have no problem of accessing gameobject that holds script

#

just how then i access udonbehaviour and its variable

dawn forge
#

That's what GetComponent<T> does

arctic scarab
#

worldcontroller?

dawn forge
#

My apologies, that is my udon script defined. I will share the two whole files to share the big picture.

arctic scarab
#

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

dawn forge
#

Ok, so you will do this gui myGuiScript = this.transform.Find("ScriptLogic").GetComponent<gui>();

Let me put it in my example

arctic scarab
#

ok it work now

dawn forge
#

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.

arctic scarab
#

so that way i can run functions from other script too

#

request serialization from other script

dawn forge
#

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

arctic scarab
#

im just having all synced variables in other script

dawn forge
#

Gotcha

arctic scarab
#

i just update them locally and then request serialization

lofty loom
#

Is there a way to make VCRUrls in the node editor with strings? since it isnt possible in udonsharp

fiery yoke
lofty loom
fiery yoke
fiery yoke
lofty loom
#

yea i get it.. i found the hardway in ~18hrs

#

but as long as i can verify... it shoudl still work

fiery yoke
lofty loom
#

welp i guess thats gonna happen

arctic scarab
#

i moved everything to other script and it still seem to not run

#

why ondeserialization so broken

arctic scarab
#
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

dawn forge
#

I'll see what I can do, at work atm

light bobcat
#

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?

arctic scarab
#

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

dawn forge
#

That's request serialization to say hey, please take my changes

#

Deserialization is "I got your answer, and I'll read your data"

arctic scarab
#

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

dawn forge
#

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?

arctic scarab
#

no im running uploaded

wind atlas
#

So you have to call it yourself.

arctic scarab
#

i saw it does fire multiple times by itself

arctic scarab
#

possibly all other synced variables havent got synced either

#

it must be host only thing

wind atlas
#

Remember that you need to be the owner to send stuff. Also, you need the attribute UdonSynced on your variable.

arctic scarab
#

all variables have this

#

and i send as owner and both non owner

#

in both cases my primary account does stuff

wind atlas
#

If you have both of these and RequestSerialization, then everyone else's OnDeserialization will be called.

arctic scarab
#

and other dont

wind atlas
#

Something else must be going on then.

arctic scarab
#

1-4 work 5th not

wind atlas
#

We need more info than just that.

arctic scarab
#

and everything up to this function does run

#

for host only because host supposed to pass info to others

wind atlas
#

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.

arctic scarab
#

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

wind atlas
#

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.

arctic scarab
#

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

wind atlas
#

As I said, the instance owner might not even be present.

arctic scarab
#

well i can change it later

#

on tests its working

wind atlas
#

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.

arctic scarab
#

so i will search for host thing

topaz jetty
arctic scarab
#

but lets fix thing not sending first

arctic scarab
#

it guarantes all will run

#

in case of int being something already

topaz jetty
#

so it changes during ondeserialization?

arctic scarab
#

damn everyone gives me fixes for code i dont need fixed

#

i need fix networking only that

topaz jetty
#

lol sorry I literally just opened the channel and it was the first thing I saw

topaz jetty
arctic scarab
#

again

wind atlas
topaz jetty
#

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

arctic scarab
#

here you got full path from start to end

topaz jetty
#

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

arctic scarab
#

im making variables there

#

and bottom variables are changes

#

passing from first script to another

#

to update synced variable

topaz jetty
#

well just make sure you're actually checking/setting object ownership

#

instance owner has nothing to do with networking

arctic scarab
#

im not changing object owner just ensuring only one person runs local script

topaz jetty
#

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)

arctic scarab
#

so am i supposed to make every remote player owner of this script on deserialize

#

to ensure every player be able to run

topaz jetty
#

no

#

you run the script in ondeserialization

#

and the object owner just changed synced variables

arctic scarab
#

so i add owner change before variable change

dawn forge
#

@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

formal ledge
#

how do i fix this issue?

#

i've saved the scene

red gazelle
#

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

dawn forge
#

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");
}

eager quail
arctic scarab
#

so has anyone found solution

west solar
#

why cant i name this?

dawn forge
west solar
#

lol

valid oar
#

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.

west solar
#

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

valid oar
#

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

west solar
valid oar
#

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.

dawn forge
#

I think you can pull the current playtime of the anim clip and use that sync

valid oar
#

Good to know, I think the one in the prefabs database does something with the system clock

dawn forge
#

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)

valid oar
#

I don't know much about Udonsharp but I'll try to keep that in mind if I need to do that.

thorn jewel
#

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?

west solar
#

can somone teach me how to do synced toggles

dawn forge
thorn jewel
#

Instantiation was, from my perspective, dynamic, only creating objects at runtime.

dawn forge
#

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.

thorn jewel
#

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?

wind atlas
thorn jewel
#

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.

wind atlas
thorn jewel
#

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.

wind atlas
thorn jewel
#

Why?

wind atlas
# thorn jewel Wait really?

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.

past patio
#

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

thorn jewel
#

It worked! Thanks!

crimson gazelle
#

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

valid oar
#

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.

crimson gazelle
#

Right, I dont need it to do anything

#

Setup instructions just told me to make that

valid oar
#

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?

crimson gazelle
#

The game object is throwing errors so I think so

valid oar
#

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.

wind atlas
dawn forge
#

You can't use GameObject because Unity already implements that

valid oar
#

Ah, that makes sense.

crimson gazelle
#

Or both

dawn forge
#

The script behavior specifically

wind atlas
#

Yeah, the scene object name doesn't matter as much.

crimson gazelle
#

I tried changing the script name already and reloading

#

I can reload the whole project

#

still nothin

dawn forge
#

Make sure your file name matches your new class name, and also the udonsharp asset file matches the same.

crimson gazelle
#

deleted the whole object and made a new one

#

threw more errors

dawn forge
#

You still have your "GameObject" script in there

crimson gazelle
#

where

#

ah I found it where it most definitely should not have been

#

I can publish now yay

#

Thank you

topaz jetty
arctic scarab
#

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"

tropic canyon
#

That's exactly what manual sync is

arctic scarab
#

so automatic is not guaranted

#

how i make it manually then

tropic canyon
#

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

arctic scarab
#

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

arctic scarab
#

yes i just checked

#

remote function runs but variable never sync up

tropic canyon
#

you need to mark it as [UdonSynced]

#

all the variables you want synced

arctic scarab
#

is it possible that because of variables are long arrays new ondeserialization starts before variables finish syncing and that makes them reset?

arctic scarab
#

just the thing they never get synced

#

probably they too big

tropic canyon
#

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

arctic scarab
#

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

arctic scarab
#

aaand can i pick which variables are manual and which automatic

#

or i have make separate files for each

tropic canyon
#

Each gameObject has its fixed sync type

#

So a gameobject can either be manual or automatic sync or no sync

arctic scarab
#

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

arctic scarab
#

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

wind atlas
# arctic scarab 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

arctic scarab
#

3 ints and 1 strings

wind atlas
#

How long are those strings on average?

arctic scarab
#

5 symbols

#

and i think ondeserialization never actually runs from that certain function

wind atlas
#

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.

arctic scarab
#

yes i do need

wind atlas
#

I disagree.

arctic scarab
#

stores all generator info

wind atlas
#

There are usually ways to send it more efficiently.

arctic scarab
#

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?

arctic scarab
#

hmm from what i see even after removing synced variables deserialization not running

arctic scarab
#

okay now it does

#

string arrays seem to prevent sync

dawn forge
arctic scarab
#

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

broken zodiac
#

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...

formal ledge
#

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?

indigo finch
formal ledge
#

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?

indigo finch
formal ledge
#

Do you know how to make sure that an Udon Sharp script does work on a prefab?

indigo finch
#

Luck

formal ledge
#

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

indigo finch
#

As far as I've seen it's really random

broken gale
#

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?

formal ledge
#

So do I have to put the script individually on every gameObject of the same prefab?

#

I can't put it on the prefab?

indigo finch
formal ledge
#

oh?

indigo finch
formal ledge
#

Thanks

#

I didn't mean to spam though, I just wanted to show the code

formal ledge
indigo finch
indigo finch
formal ledge
formal ledge
indigo finch
formal ledge
# formal ledge

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...

indigo finch
# formal ledge

It's not shown in this image, but is this a prefab inside another prefab?

indigo finch
#

Then you will have to unpack the overlording prefab ^^

formal ledge
#

Okay, I just put in another prefab by itself that I will unpack for testing purposes

indigo finch
#

Good call

formal ledge
#

Okay, I just unpacked it, not sure what that does though

indigo finch
formal ledge
#

ah

topaz nest
#

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?

broken gale
formal ledge
broken gale
indigo finch
formal ledge
#

But it does work when testing in Unity with the VRChat Client Simulator

indigo finch
topaz nest
#

Is that possible with udon?

formal ledge
#

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

indigo finch
# topaz nest Is that possible with udon?

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

indigo finch
# formal ledge It does output to the log when I test in the VRChat Client Simulator, but it alr...

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

formal ledge
#

okay, I wish I could test it in the VRChat Client Simulator because it takes much longer to troubleshoot through VRChat

indigo finch
topaz nest
#

And using the particle as variable

broken gale
# indigo finch Glad your finding them helpful ^^

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!

▶ Play video
indigo finch
broken gale
#

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.

indigo finch
alpine rampart
#

does anyone know why my cameras are picking up phone cameras and controllers in vrc even though ive turnt of ui?

indigo finch
indigo finch
formal ledge
#

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

thorn jewel
# topaz jetty Ususally you use a player object pool when you want a networked object for every...

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

formal ledge
#

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?

wind atlas
#

Haven't used that in a while so not sure how exactly it works.

formal ledge
#

I should put that in my gameObject's udon sharp script instead of having a VRC Object Sync component?

wind atlas
formal ledge
#

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

wind atlas
formal ledge
wind atlas
formal ledge
#

Oh, okay

thorn jewel
#

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).

topaz nest
indigo finch
#

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

formal ledge
#

The sync.setKinematic did it!

#

I wouldn't have guessed, I had been doing rigidbody.isKinematic = false

shy osprey
#

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?

broken gale
#

What's the best way to copy + paste numerous materials onto an object or material array?

light bobcat
#

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.

formal ledge
#

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

shy osprey
#

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

summer scroll
#

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.

wind atlas
wind atlas
#

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.

wind atlas
nocturne flume
#

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

wind atlas
tropic canyon
#

Are there no errors when running the code?

nocturne flume
#

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

wind atlas
formal ledge
wind atlas
#

You could handle the auto respawn yourself. The scene descriptor has a height, which you could turn down. And then just detect it yourself.

nocturne flume
wind atlas
#

Btw, you don't drag the "variable" you drag in the other script that you created in there.

nocturne flume
#

I set them all to public . Also I tried to drag a script but won't let me either

wind atlas
#

So drag in the gameobject/component instead.

nocturne flume
#

thank you so much 😁

broken gale
#

This is so annoying, I swear.

wind atlas
# broken gale

You have to drag them into the "materials" text, not the individual field.

broken gale
broken gale
wind atlas
#

Hmm, this might be a udon graph issue then. I'll try it out myself.

broken gale
wind atlas
broken gale
wind atlas
# broken gale 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.

wind atlas
broken gale
wind atlas
broken gale
#

Got it. Thanks.

scarlet lake
#

Hello, there is any guide on how to make a simple combat system with udon?

timid sandal
#

What do I do when the wheel where you have options, emoji, and expression doesn't work at all?

timid sandal
#

Ok

indigo finch
scarlet lake
#

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

summer scroll
#

do we still need to use dynamic bones in worlds?

valid oar
#

Yeah, no physbones yet.

hallow sable
#

is there a way I can have a text display the players name who interacted with a object?

#

using udon sharp

hard holly
#

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

broken gale
#

Is it possible to remove the object interact outline?

indigo finch
#

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?

winged prism
#

Hello! I'm new to VR in general and was curious about changing avatars to custom ones

tropic canyon
dire shore
#

Hey guys, I'm getting an error when trying to access the Length property of an array in UdonSharp

topaz jetty
#

it's saying that your array doesn't exist

dire shore
topaz jetty
#

error is at line 57 it says

#

which line is that?

dire shore
#

the Debug.Log

topaz jetty
#

did you do anything different?

dire shore
#

It's working now, apparently it wasn't compiling before I hit Play

#

thanks for the help

dawn forge
#

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.

grand temple
#

you can definitely sync string arrays

#

just needs to be a manual synced udonbehaviour

#

@dawn forge

dire shore
#

Does Matrix4x4 works in UdonSharp?

#

It isn't changing the matrix values

brazen epoch
dire shore
#

oh thx now it worked when I used the matrix constructor

arctic surge
#

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

broken gale
#

How can I make this happen? Ahaha.

jolly osprey
#

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?

floral dove
jolly osprey
#

1 yes
2.it was 0! Ty for helping!

floral dove
broken gale
#

I'm at my wits' end. Why doesn't this work?

floral dove
#

if you're targeting the UnityEngine.InputManager and not your own class

broken gale
floral dove
broken gale
broken gale
floral dove
#

Right, those are not exposed to Udon.

broken gale
#

Nor InputManager, nor VRC.SDKBase.InputManager? Unless those are the same.

floral dove
#

Oh my bad - yes, you shouhld be able to use EnableObjectHighlight, passing it a boolean and a GameObject or Renderer to control.

broken gale
floral dove
#

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.

slim hound
# broken gale

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()

broken gale
zealous cedar
#

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.

tropic canyon
#

You can call Drop on the pickup object to make the localplayer drop it

zealous cedar
#

(object).Drop();?

tropic canyon
#

VRCPickup.Drop

arctic scarab
#

sooo how i detect pressing the pad stick buttons

scarlet lake
#

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

limpid umbra
#

Does anyone know if the udon kart system works with sacc flight?

torn shuttle
limpid umbra
torn shuttle
#

I have gotten so distracted, It works with Kirby flight and with Puppet's flight
I think itll work with sacc,

arctic scarab
#

how to detect pad analog button press

scarlet lake
#

anyone know what makes this local (screenshot pls)

coarse parrot
scarlet lake
#

where do i put it

#

oh

#

wait

#

im dumb

#

someone know how to take the number of the players inside a box collider trigger?

white fractal
#

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

dawn forge
white fractal
#

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

dawn forge
#

You'll need the station to override your locomotion controller https://docs.vrchat.com/docs/vrc_station

See Animation controller parameter

#

And on your controller you implement the crouch/prone animations

white fractal
#

if the avatar has a costom animation controller can i grab it ant put it on the station

dawn forge
#

I think only for sdk3 you can not grab but only apply your controller

#

And override

white fractal
#

so is there a way for the station to grab the players locomotion controller then

dawn forge
#

You'd not know what layers or parameters they defined

#

Even if you could...

white fractal
#

for the moment would it basically be making a stranded unity player controller but binding inputs to VRC player inputs

odd sapphire
# white fractal if the avatar has a costom animation controller can i grab it ant put it on the ...

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

This guide will go over how to use the Repositioning Remote Players technique to create what appears...

white fractal
#

is therw a way to also prevent the station locking the players yaw rotation

dawn forge
#

Add a constraint

white fractal
#

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

odd sapphire
#

try to use station's player mobility as Immobilize for vehicles and detect player's head/mouse rotation and with that rotate the chair vrcCatThink

white fractal
#

how do u disable players rotation on the yaw

arctic scarab
#

how i detect analog button press

floral dove
#

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.

grand temple
#

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

floral dove
#

This isn't #udon-arguments 😛

#

We protect the player's transform to stop all sorts of attack vectors that people could take.

grand temple
#

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

floral dove
#

Is there a particular problem you're trying to solve, or a feature you'd like to see?

#

could you be more specific?

grand temple
#

there's definitely room to add more things but it wouldn't ever be done by just giving you a reference to the transform

floral dove
#

You're welcome to do so on our Canny!

pallid roost
#

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

floral dove
#

That's right, you've just described how security works in Udon. We have to wrap everything to allow safe access.

grand temple
#

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

floral dove
grand temple
#

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

pallid roost
floral dove
#

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.

pallid roost
grand temple
#

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

gritty wraith
#

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

echo steeple
gritty wraith
#

Listen I’m so sorry I got redirected to this channel by another member. I was just following where they told me to go

echo steeple
#

Lol don't worry about it. Shit happens. Just letting ya know. Wish ya the best regardless

grand temple
#

yep

white fractal
#

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

pallid roost
#

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?

dawn forge
#

Is that at the same angle, player 1 and 2 in the same spot?

pallid roost
#

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

dawn forge
#

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?

thorn jewel
#

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".

thorn jewel
#

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?

mossy thunder
#

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?

mossy thunder
#

well figured that out. nvm

scarlet lake
#

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

mossy thunder
#

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...

scarlet lake
#

ye since i got more teleport for more cases and this happen with only one of them

mossy thunder
#

hrm. why does it need their current location as a subvalue of the respawn index?

scarlet lake
#

because it is an array of respawn points

#

well I can try making it just one and see if it will work

mossy thunder
#

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?

wind atlas
#

Where are you calling that teleport? In Update? Or somewhere else like OnDeserialization?

scarlet lake
#

in update

wind atlas
scarlet lake
#

it is inside a FixedUpdate 🤔

wind atlas
scarlet lake
#

nope, looking how I should delay it

wind atlas
scarlet lake
#

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

mossy thunder
#

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?

wind atlas
mossy thunder
pallid roost
mossy thunder
#

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.

wind atlas
wind atlas
mossy thunder
#

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.

wind atlas
wind atlas
mossy thunder
mossy thunder
scarlet lake
#

how can I teleport the player remaining inside a box collider when someone left that box collider?