#udon-general
59 messages · Page 64 of 1
to the same number every time, or to something else?
so I can set it to -1
oh, you need a float const node
yeah, just a series of branches to make sure that every case is observed before doing the respawn
then it will transfer to them and they will do the respawning
but they'll still receive the onenterstation from you, and so the float will be -1 and they won't respawn it until you get off
Which node outputs parents to an obj?
transform getparent
I tried that one, it doesn't connect to IsOwner
unless there's more than one IsOwner and I haven't noticed
This is what I've done so far, I know I need to connect the gameobject up
or do I?
It should be getting it from the getparent at the start, no?
this part is not correct. You're checking if timer is greater than timer + 30 but that will always be false. You need to check if time.timesincelevelload is greater than timer + 30
the ownership check looks good
yep
also make sure you're plugging something into objectsync respawn. Easiest would be getcomponentinparent (vrcobjectsync)
Does it have to be blank?
I have one in this graph but the type is set to vrc_pickup
what, getcomponentinparent?
the instance there can be blank because it's just looking for a transform. Transform, gameobject, and udonbehaviour will always self-reference in graphs if left blank
So I should make a new one
I'm not sure what you're asking
I was just trying to re-use a node I already have
but it has a type attached to it
I wasn't sure if that would affect it
yeah you don't want to directly re-use it because it's not the right type. But you could copy it and then change the type
which type?
vrcobjectsync
alright
that's what respawn is looking for
So will that cover both sitting and picking up?
oh right, you'll want to set the float to -1 onpickup and time.timesincelevelload on drop as well
How would I refer to the parent in that scenario?
since I can't attach anything to events
the parent has the onpickup and the child has the timer float. So just have onpickup > getcomponentinchildren (udonbehaviour) > setprogramvariable "timer"
or you could rearrange it so that the variable and the update loop is on the parent, that may make more sense
The reason it's on the child is because there were some issues with it being on the parent
I can't remember what the issue was, but having the script on the seat fixed it
like what, being able to detect onstationenter?
that might have been it but this was a few days ago now
you can't detect events like that happening on a separate gameobject. That's why you put a script on them and then send the events or the variables back to another script. You're going to have to communicate between them somehow
I feel like the way you suggested is easier
I would also just recommend having public udonbehaviours on each to refer to eachother instead of doing getcomponent all the time. It's not a huge deal since you're not doing any of this every frame, but it does reduce the number of nodes going on and also allows you to make use of the fancy dropdowns on setprogramvariable and sendcustomevent
getcomponent is relatively expensive because it has to look for things by checking a bunch
I assume I'll need to make the timer public now
yes
wait I mean no
setprogramvariable can set private variables
in udon, public really just means that it will show up in the inspector. Which doesn't exactly match C# but oh well
yeah, that's what made me think I'd need to
so just make a variable with the same name then?
if you want to move it, yes. If you want to set it on another udonbehaviour, no
It's just that I don't see how I'm meant to refer to it otherwise
setprogramvariable
if you have the udonbehaviour as a public variable, it will populate the dropdown with that program's variables. If you are still using getcomponent, you have to plug in a string const and make sure it's spelled exactly the same including capitalization
no, the instance is left empty so that will refer to itself
you need to do getcomponentinchildren (udonbehaviour)
I don't see it under udonbehaviour
I mean gameobject getcomponentinchildren, then plug in the udonbehaviour type
no, not that
yeah, I typed "type" a little too quickly
I dunno
with that swapped, is that everything?
yeah probably
Just to be sure, what happens when the world starts and nobody has touched anything?
oh yeah, you probably want the default value to be -1
but worst case it would just respawn to where it already is ¯_(ツ)_/¯
I suppose having an object teleport an inch every 30 seconds isn't bad
well after respawning it, you want to also set the variable to -1 otherwise it will be respawning every frame
So I just tack that on the end of the script
on the update loop, yes
would it be better before the respawn? I don't know how it works but I can imagine it might have the chance to trigger a few times
it does not matter since everything that goes through the flow happens instantly. There is no possibility for udon to execute this twice before it's finished once
Oh right, white line and all that
if you have some really complicated math that takes time to do, it will freeze the game entirely until it is finished
I was thinking about lag and stuff, I used to write E2s for garry's mod and sometimes you'd have to account for that kind of thing
yeah, then it probably ran on multiple threads and so you can have different threads doing different things or even the same thing at the same time. But udon at the moment always runs on the same thread, so performance is worse but it's much easier to keep track of everything
VRChat needs multithreading joke goes here
plenty of other things are multithreaded, especially constraints, networking, and voice transmission. Making code that is multithreaded is one thing, making a VM that allows people to make their own multithreaded code is another thing entirely
first one is on the seat, second one is on the pickup
neither of them cause a respawn after 30 seconds
just in case, I'll compile again and make a new build
maybe it just didn't apply
nah, didn't help
everything compiles just fine too
not crashing on compile, I mean crashing ingame
check your logs
ah, vrcobjectsync GetType is not correct. That's asking for a vrcobjectsync and will give you the objectsync type which is... not what you want. Probably one of those weird auto-generated nodes that isn't really useful.
Instead you need VRCObjectSync Type
I tried looking and I have no idea what folder this node is in, but again if you don't know where it is you can always find it in the full search with tab!
it works when you sit, but not when you grab
sounds like the script on the pickup is crashing from something
I can send you the log if you want
you can look at it yourself, just search for "halt"
no halts
ok, then it's not crashing. Try adding a debug log after the setprogramvariable to make sure that's happening
Searching for "Log" should bring it up as the first option
inside the log itself?
They are nodes in the graph that you add to debug your udon programs
You should just be able to search for whatever string you were logging
How do you have the log in the udon graph setup?
Anyone got any ideas for raycasting to detect the presence of a player?
Right now what I've tried is the box collider on a canvas UI from this article on player tracking http://vrchat.wikidot.com/worlds:guides:player-tracking
My layer mask includes both the Player and UI layers but the ray doesn't seem to work with players, at least in "Build and Test"
the log was triggered twice, once when I picked it up and once when I dropped it, so it's doing everything without a hitch
What's your current setup, that article is probably not the best thing to follow as it's for SDK2
SDK3 and Udon
Yeah I was asking more of the udon behaviors and how they are set up
Basically just raycasting in the forward direction from a GameObject
If you were trying to follow that article it would be a fairly roundabout way to do it in udon
So does each player have their own raycast or does each player have their own collider?
Each player should have a collider that is detected by a raycast
And blocked by objects on the default layer
The raycast is blocked I mean
So do you have an objectpool that assigns them to each player?
I haven't done that, I associated the canvas element with the main camera, I thought that would populate it
I can give that a shot though
Basically just what that article said, but with a bigger box collider
Udon has built in functions to do all of that without the roundabout methods
You should ignore that article since you are using Udon
If you have an object pool you would assign an object to each player and give them ownership of it, then in the graph get owner > get position of owner > move game object to that players position
I'll start working on trying that out, just to be clear I create a pool of GameObjects collider components on an appropriate layer that no actual collisions happen, assign them to players as they join, then raycast against the GameObjects that are on each player? With the GameObjects updating their position every tick?
Yeah, for the raycast though you would need to use a networked event or alternatively have an object pool for giving players the raycasts also
Cool, sounds promising. Thanks for your help!
Can you see anything wrong here node-wise?
I suppose it looks fine but I have never used GetComponentInChildren
I prefer GetChild as you can give it an value of which child specifically
Though you only have one game object as a child right?
suppose I manage to make it work with just 1 child, what would I do?
that other part works perfectly for what it does
all that second graph does is poke some new values in
What does the respawn function look like?
And to clarify that is the part that isn't working right?
This part works great for the seat (which is what the script is attached to)
so things respawn correctly 30 seconds after getting out of the seat
but the other part is what's wrong
Wrong how?
can you just try using public variables instead?
That's what I'm trying to work out
all I know is that it doesn't do what it should, and instead does nothing
do you just make a new variable under the same name?
I mean to replace all the getcomponents
manually define exactly what you want to do instead of just assuming that it's set up a certain way
On both scripts?
yes
I'm back, PC was nagging me about updates and stuff
I realised something though
Is there a chance that the pickup script could be interfering?
you're going to have to get it the rest of the way yourself. There's a lot you can do to find out why it's not working. Try logging every step of the way in the update loop so you know where which part is stopping. Try logging the variable so you know what's happening. Try logging the name of the gameobject you get from getcomponents so you know for sure it's getting the correct thing.
trying to make a toggle where you click it and npcs disappear and appear, like On/Off but for multiple objects and this isnt working so far
I’ve read so much and tried to learn but it doesnt work
You would want to do this
alright I’ll try it later thanks
they wont turn on again if I click the button
They turn off and then they wont turn on anymore
Show graph?
In the inspector in the object array you don't have any missing elements do you?
what do you mean by that
you mean the array where I put the things turned off and on
Yeah
no since it's turning off properly
there is something with the graph or something
the sync method is contineous
the first time I click it, it's doing what it should, but the npc's wont come back when I click it again
Are you testing in game or in editor with CyanEmu?
https://github.com/CyanLaser/CyanEmu/releases/tag/v0.3.9 Get this and test in editor play mode
but it didnt work in vrchat
Yes that will make it easy to figure why it didn't work
someone told me to make a bool to fix my array
maybe thats why
he told me to do this
but I didnt understand how
What are the NPC objects you are toggling?
Can you change the udon behavior to toggle a couple of cube game objects instead and see if that works?
okay I'll try
yeah the cubes work
the thing I am trying to disable is a trigger with the model as a child so I disable both the trigger and the model
cause it would be weird to speak to a non existent npc
Yeah that's kind of what I figured
Something with the NPCs is changing when you toggle them
If you get CyanEmu you can test in editor and see what is happening
Or you could just go into play mode and toggle them manually
hmmmmmm
I'll try and see if it works if I seperate them
like not being parents and childs
then I'll try like you said
@slim hound this fixed it
thanks for the graph!!!!!
you are a lifesaver
is it possible to make a working boat that you can drive
basically just a car but just shaped as a both or used a finished model and add some sort of graph to it
that is already posable
you could look up varneon on yt he makes realistic driveable cars
okay
I am also wondering if it possible to make where u click on a toggle and an animation plays, but you can only press it once and then you gotta wait until the animation finishes or a certain time before being able to toggle it again
for some reason when I jump avatar pedistals like go invisible but when I am on the ground I can see them
Yes you can disable buttons for x time while animation is playing
this disappearing when you jump has todo with culling to over aggressively
If I Destroy a synced gameobject, does it destroy it for all players or just locally?
just locally
hey guys , i did a small graph to change the colour of an object when a player step on it . I put a cube as trigger but nothing ever happens and idk why . I don't think that the animator part is falty since i tested this specific part and it was working
Wrong events, you will want to use OnPlayerTriggerEnter/Exit
What counts as an update to the update event node?
many thx 👍
update happens every single frame
ah, that throws a theory out then
I was thinking that whatever I was doing on the external script wasn't counting as an update
as if an update happens when there's a change of some kind
Is it possible to only use 1 OnPlayerTriggerEnter event for multiple SetBool ?
I'm making multiple trigger zone and Idk if I need to make a graph for each one of them or just making a single graph for everyone
Can you explain a bit further as to what you want to do?
Also in your use case it might help for you to know that OnPlayerEnterTrigger will trigger whenever any player enters the area not just the local player
I want to make a system where I can detect how much person there are , there's 8 platform and when a player step on it the colour goes white to green , if the player isn't on it anymore it turns back to white
Thinking about it this is extremely dumb , I could just make a graph for the material switch part and then do something to count how much person there is when someone press a bouton
problem , idk how to do that
You could use the OnPlayerTriggerEnter to count how many there are too
You would just need to branch for either local player or master
what's the use of knowing if the player is local or master ?
Otherwise everyone will add to the number when they see someone EnterTrigger
So one player entering will add 5 if there are 5 people in the world
how do i make where if you throw a object of the map it respawn
Adding an object sync component will give it that behavior
also what making a object bounces
On the collider you add a physics material
i meant for when it falls off
Falls off?
so say the object gets thrown off or bounce of how do i get it to respawn
Add an object sync and if it falls out of the map it will respawn
Other than that you would do ObjectSync.Respawn or transform set position to move it back
what do i add nexted
#udon-general message You could go back through this conversation as it explains a lot about respawning an object
what is timer and single under
Local player means yourself. Everyone in going to have a different opinion on who is local. This is important for when you want something to only trigger for you but not when you see someone else do a thing
Example: a jump scare in a horror map. lol
Master - I have not had any use for this in udon. Useful if you want the person who has been in the room the earliest to have special abilities I suppose
also i have the udon timer but i dont see just timer
because in this it say timer but when i try to find its no were
ok thx for the answers
?
how do i get the single and timer when have the udon for it
They will be under float
timer is a Variable in this graph, you need to create it
ok so i ran into a problem where i have to add this in order for it to connect
If you are very new to udon it might be worth to watch a few tutorials of the basics
but if you have video for i mean that could help
Just watch some of these to get a better understanding of what things do https://www.youtube.com/watch?v=7yuj7X0-OuI&list=PLwEtUGCdQX7HMkFCVxiNvO4DS2CmHWbe6&index=9
Let's say you want something to happen when you push a button, but not right away. Well, we can set up a timer to do exactly that! My apologies for any audio weirdness, but I refuse to turn off the air conditioning right now and did my best to edit it out. The trucks going by however didn't manage to get edited out.
Note: If you'd like the timer...
i watched that already it didnt help thats what i looked before coming to u guys
You're doing "Get ComponentS" instead of "Get Component." You're likely only looking for one.
does this look right
So that I can get a quick breakdown, what is it you're trying to do?
anyone know why pool tables cause my FPS to drop to 10?? please help
Some of them might be older. Newer versions are far more optimized
i am the only one in the room fps drop
is it my 3090???
Is this a world you're creating? This channel is for creators looking for help and feedback on using Udon.
ohhhh. ok. thanks
How do I make the pick able object global
Add the "VRC Object Sync" component, and that will sync your object's movement and physics to other players.
A question.
Is Udon applicable to VRC worlds, or can it be used for setting up unique animation for avatars as well?
Worlds only, though you can do a lot through Avatars 3.0!
where can i find this under
that looks like a variable, but it's very very old. Nowadays variables are added in the floating window on the left with the plus button
if that's a picture from your own graph, make sure you have the latest SDK. If you're following a tutorial, find a more up to date one
So this took me longer than it should have.
Time to toggle objects again, but this time, for everyone! You'll see that syncing is a little bit more complicated than it was in SDK2, so to set everything up we have to tell every player to toggle that object, but also catch up anyone who joins in after the button was pressed!
All assets are availab...
Anybody aware of the workaround for Dropdown.AddOptions? I'm trying to dynamically update the dropdown menus but udon doesn't support List types, so i can't ? (forgive the noob)
Unfortunately no, you cannot
☹️ bugger
Best you can do is create your own version of a drop-down out of buttons, vertical layout group, and instantiating
hooo baby -.- I'll er.. consider that. thanks Phase
Just asking if possible. Can you make a box collider not allow portals to be placed in them? I don't see it as a feature and curious if it can be done with udon by deleting it or straight up not allow it
though if it is possible how can I make one
cause idk how you can get a gameobject thats spawned and delete it
The most reliable way of preventing portal drops is using spawn points
If you make the box collider an assigned spawn point on the scene descriptor it will give users the "Portal too close to spawn" message when they try to drop one
You may need to have multiple depending on the size of the box collider
I was hoping I could just scale the collider and it work. but I guess I just have to useless spawn points. only testing
Hopefully there's another way
Or a way of discouraging it like respawning them
Is this still a feature? I'm trying to create an object that can be held in 2 places.
It will make the entire root + children part of the pickup points (as one)
If you're aiming for a two handles type of pickup, you need to handle that differently
Is there a way to "Unload" a Video Player? Basically I just want to release the resources on demand.
videoPlayer.Stop() ?
Stop doesnt unload the video. It simply stops playback.
Stop should release the resources, at least for the Unity Video Player
https://docs.unity3d.com/2018.4/Documentation/ScriptReference/Video.VideoPlayer.Stop.html
The weird thing is that youre able to Play() after Stop() which plays the video
So does it "remember" the last video and fetches it again?
Hm - there's not a direct 'callback' pattern available, but you could have a variable that uses an OnVariableChange event - pass that into another program, and when the variable is changed your first program will receive an event with the updated value
it's more like C# properties than callbacks, but may get the result you want
How can I set a variable in a udon graph using a separate udon graph? I've tried setprogramvariable attached to getcomponentinchildren, but that didn't seem to work too well
https://docs.unity3d.com/ScriptReference/Video.VideoPlayer.Stop.html
This also destroys all internal resources such as textures or buffered content.
I use a pattern where I have an array of UdonBehaviours that acts as a "subscriber" list. When an event happens, I iterate through the array and do a SendCustomEvent to all valid Behaviours in the array. I use the array as a ring-buffer with an additional indexing integer that overflows at Length back to 0 and increments whenever you add a behaviour and skip over nulls unless no slot is available.
However this only works for events without parameters.
Hmm weird. As I said, you can Play() after Stop() and it will just work
Yeah - Play() will prepare the media for playback again https://docs.unity3d.com/2018.4/Documentation/ScriptReference/Video.VideoPlayer.Play.html
Ahh I see it works because the actual video file is kept in a temporary memory somewhere.
That is how you do it yes. The set program variable needs a reference to the actual udonbehavior though. Also when selecting the variable name from the drop-down there’s currently an off by one error. The name of the node is the variable you are modifying not the name in the drop-down
There's a drop-down?
I'm on the latest SDK and I've not seen that
This is what I tried last
It was suggested to me to use public variables, but I broke something in the process and reverted
Is there anyway to detect if a player is crouching in udon?
Does anyone know a good way (or asset) to make good looking volumetric spotlights that are VRChat compatible?
have you tried asking in #shaders? I feel like you'll have better luck there
I've definitely seen volumetric shaders before
Ahh, yeah that does seem like a better channel to ask in
I'm working on a world where I want people to be able to move forward and back through pages of text using text objects that appear and disappear in a sequence. I would imagine this would be done via an array that would store the various game objects and then hide the game object at the current element and show the one at the previous or next element depending on whether the button to go forward or back was pressed. I think that's how it would be done but I don't know how to translate that to Udon. I know there's a prefab that allows for different materials to be swapped so I could do it that way but that only goes in one direction and using text objects seems like it will use a lot less space than having a bunch of materials with their own textures.
I could hard code it so if I press the forward button on page 1, it has a script that hides page 1 and shows page 2 but I'm planning on having dozens of pages and making a separate script for each wouldn't be ideal if I can avoid it.
take a look at the 'Chooser' in the UdonExampleScene, it does this with the demo prefabs
synced, even
I will do that, thanks.
i have a question, anyone know how i can make a Trigger for Toggle GameComponent ? Like when i Trigger it, it will turn off the Animator inside the Object but the object stay On.
Sure - you can make the Animator a variable and then control it's 'enabled' value or have it Stop()
waht you mean exacly? i have my little problems with the Udon Graph 😅
How far have you gotten?
Not very far xD I can't even create a simple trigger without help😅
ok - there's a ToggleGameObject program on the MirrorSystem that demonstrates turning an Object on and off. Can you get that working first, then we can change it to make it control an animator instead?
https://docs.vrchat.com/docs/udon-example-scene#mirrorsystem
I don't need that for an animator to be honest. I want to insert a button that allows you to turn a pressable button into a clickable one. depending on the user is in VR or desktop
Ok - the example here will show you how to use the 'Interact' event to make any object clickable and run some logic, that's a good place to start: https://docs.vrchat.com/docs/udon-example-scene#interactcube
okay thanks i hope i can work with that
once you know how to use the Interact event and you have that working, you can then add an Animator variable and control that instead
@grand temple I finally got it all working, although I noticed a minor issue
If someone is sat in the seat and then someone picks it up and drops it, the 30 second timer starts back up and the seat will respawn with a player sat in it
this is what I ended up doing, a public variable that points directly to the seat like you suggested
so add a bool for when it's currently being sat in and don't set the float if so
and likewise for being held while getting out of the chair
station seated, right?
yeah
you're just allergic to public variables aren't you?
I tried using the public variable I already had, wasn't sure how it could connect
is it a vrcstation variable?
It's less that I'm allergic to public variables, and more that I'm allergic to knowing variables have types
Has anyone had this problem? Vector types wont display properly, they're totally busted
just reload the graph at the top right
oh that bug, yeah it's known and will be fixed soon
Oh okay, thanks for the heads up o7
actually wait, what kind of constructor is that?
I should reword, I was trying to construct a ray with the box that was broken
ray constructor looks like this to me
Yeah, the X boxes stretch horizontally to the point where everything to the right is pushed out of the node canvas
let me double check with the latest SDK
ohhh it's a vector3 const node, not a constructor
Theres both a ray constructor and a Vector3 node thats busted
Seems to be whenever theres more than one column of values
ok, thanks. That one is slightly different to the other issue so it was not on the radar
Hooray for finding bugs. I was hoping this might be some common simple fix thing which is why I asked here first but thanks for discussing this with me, ill see if I can get it reported if I can't fix it.
already thrown it in the pile, don't worry about it
Oh, much appreciated ^-^
if you need a workaround for now, though, it should work if you just plug public variables into the slots
if the slots have something plugged into them they won't display the full inspector so they will properly display the output
or if you want to define it in the graph instead of the public variables, you can use a vector3 constructor node
Is get seated definitely the right node?
I just tested it with a friend and they still respawned
probably, but it may only work for the local player
I'm asking because "seated" is a checkbox on the station script itself
I don't think it's related to whether someone is in the seat
but I can't be sure
oh yeah you're right, that's a property that changes how you attach to the station
Hmmm
just set a bool onstationenter and exit
alright, give me a moment
Thought I'd try asking again. Anyway to delete created portals in within a collider?
you mean you want the world to prevent players from placing portals in a particular location?
yeah
The most reliable way of preventing portal drops is using spawn points
If you make the box collider an assigned spawn point on the scene descriptor it will give users the "Portal too close to spawn" message when they try to drop one
You may need to have multiple depending on the size of the box collider
So there really is no other way
box collider didn't change anything when I tried it.
but if you want to deny a specific location, then yeah I'd recommend spawn points
spawn points I'm guessing only cover 4 square meters
So how would I make them not a actual spawn point
udon has an onrespawn event, so when that happens just teleport them to where you really want
oh, onspawn not onrespawn
alright, ty
you can have the Spawn Order be 'first' and put your portal-protection spawn points after the first one
I think? Never used anything but 'Random' for Spawn Order
How's this? the seated bool is set by the onenter and onexit in the other graph
you're setting it to -1 onpickup, so that's not the one you want to block if they're seated. You want to block the one that's causing it to actually get respawned, which is the ondrop
what if someone sits and leaves?
while someone is holding it?
now you mention it that's a very specific set of circumstances
the time will be set by whichever event comes last
does quitting VRChat count as onstationexit?
I have no idea
Hopefully it does
otherwise it's possible for someone to sit and then quit
and then that chair is technically being used the whole time
(until someone else sits in it)
That's not what you want. Setting it to -1 prevents it from respawning. If you pick it up, you always want to prevent it from respawning
Is that in reply to the graph I just put together?
yeah
I notice that when I play an audio stream online and I put an effect, like reverb, all of a sudden the volume is maxed out and it can't be changed
Seems like a bug?
so which way should the branches be?
onpickup and onstationentered shouldn't have a branch at all
I thought I needed that to check if the seat is being used
since I've got this bool that determines if someone is sat down
yes, but you're using that to prevent it from being respawned when someone is sitting
picking it up doesn't start the respawn timer, it stops it
Is there a way to set all of the objects in an array to active? I tried reverse engineering the chooser script and came up with this but it doesn't appear to work. Do I need to cycle through the array and enable all of the elements individually or can they be handled as a group?
you need a for loop
alternatively you could put all objects under the same parent in the hierachy and toggle that parent instead
Unfortunately they need to be parented to different objects because those are all in another array that is being controlled by the chooser from the Udon Example scene. I have a very limited background in programming so I know how those work but not how to create them with nodes. Is there a tutorial you could recommend for that sort of thing? Most of the tutorials seem to either be very basic or focused on advanced networking.
That's great, really appreciate it. It kind of even makes sense at a glance which is always nice.
Is there anyone having this same problem ? where the Upload just fails MID upload like 50 times before I can finally upload it ? It gets really annoying
I am starting to go little crazy 😵
Is Udon running c# code in real-time or does it get compiled like when Kotlin compiles Kotlin code to java code? And since if there's another high-level added, how much of a performance decrease would it be if i wrote in c# rather than using the Udon system?
So both udon graph and udonsharp compile to udon assembly using IL2CPP, so udon# will be just as fast as udon graph
Any overhead (comparing to before Udon) to keep note of? Thanks for all the replies!
well udon is not as fast normal c# as there is indeed overhead on it but there is no way around that for vrc your only scripting abilities are udon, still udon is quite powerfull i never found it slow
Ah, bummer. Cheers!
I want to teleport the player who toggled the button with their names on it. So far I made a udon can get the displayname who interact the button, but it’s only work locally. Need help.
why do people keep implementing on ownership transfered
anyway what you need todo, isa syncronised variable of type string that you call like displayname
and instead of setting the text directly you should change the value of displayname and than request serialisation
then you need to alt+drag that new variable to create an onchanged event for that variable and in there you can update the textfield
like this
Thanks a lot, didn't notice I haven't update my SDK...
Ah yes the variable changed stuff is very recent
Is on variable change executed even when variable is not changed (manual sync RequestSerialization)
I never tested that, but it would be pretty wierd if that is the case
it's only executed if:
- You change the variable with SetProgramVariable
- You change the variable with SetVariable and 'sendChange' turned on
- The owner of the object changes a synced variable using one of those methods
Is there anyway to detect crouching in Udon?
Not directly but you could likely detect it fairly accurately on a humanoid avatar by checking bone positions/rotations
Sounds good. Thanks
So, I've looked everywhere and can't find any good info on timers. I need a simple timer that after a collision waits x time and the continues on the graph. Watched a video or two, but was looking more for documentation... of some sort. Any info would be great 😉
you're looking for sendcustomeventdelayed
yee! thanks
Hello, I have a little question: Is there a node in Udon that is basically the C# equivalent of "WaitForSeconds" so I can for exemple play a sound then wait 1 second and then teleport the player?
Oh wait, I think the question above answers it X3 Sorry!
Guys I cant seem to find (transform.set position)
type Transform, press Enter, type setposition, press Enter.
here's all the ways you can search for nodes @random orbit: https://docs.vrchat.com/docs/searching-for-nodes
Thank you
Im having some issues with a graph that i made for some reason the door doesnt move but you can walk through it like hit has opened
is the door's gameobject set to static?
Yes
Does anyone know how to keep a player stable on a platform? Thank you, if you can help
the only way I know of is to put them in a station
Can you please show me, I’m trying to make a subway train and through the seats a do-able I want people to be to walk within the collision mesh
there's a demo station in the UdonExampleScene that shows how to put a user in a station: https://docs.vrchat.com/docs/udon-example-scene#vrcchair3
Ahhh thank you for your help
you need to use our special wrapper for it - full details here: https://docs.vrchat.com/docs/video-players
Using the Prefabs The easiest way to put a Video Player in your Udon world is by using one of the Prefabs, which you can find in Assets/VRChat Examples/Prefabs/VideoPlayers.Both of these prefabs will play a video of your choosing, synchronized for everyone in your world. They won't loop - the graph ...
Oh I see, I wanted to play a local video, which I didn't see the option to use on these ones.
not currently supported, sorry
The workarounds are listed on that page! You can host it on a server and provide a direct URL link, or use one of our supported video hosts.
I need local videos cause I need movie graphics for WWE entrances in my arena map, if I used those, I wouldn't be able to load all those graphics at once because of the rate limit.
(For context)
right - if you want to have multiple videos playing, you'll need to queue them up with 5-second-ish delays when someone joins
Yeah that unfortunately wouldn't work out, it'd take too long for all the graphics to change.
how many different videos are you trying to load at once? Could you combine them into one?
5 graphics.
1 for the main tron, 1 for the mini trons below, 1 for the floor ramp tron, 1 that's used on the ring apron and ring corner post trons, and 1 that's used on the side stage (and arena ribbon) tron.
If I could put them all in one, that would make sense, but the each of the graphics usually has their own different time length, making looping very difficult
Quite the sticky predicament I'm in.
oof - you're likely to suffer a pretty big performance hit trying to play 5 videos at once on most machines. You could instead put them all in one video and split it up using UV mapping to have it play on the right sections of your models.
if they're very short, you could try turning them into sprite sequences and playing them through animators, but that can take quite a performance toll as well
no, you're trying to do a complex thing 😛
True, lol
I should mention the videos are pretty short, usually a couple of seconds long on loop
At least for everything but the main tron graphic, which is usually a good bit longer.
You could combine them all into one video and loop the shorter ones long enough to match your longest loop, then map them all to the different surfaces
then you only need to load and play one video
I can try that
ETA on dynamic loading of externally hosted images?
That's what I did for the TVs in my Asylum map. It worked out pretty well. Here's the base video that I used. https://youtu.be/FAW0dkscA7I
I don't own the music, this is just for a VRChat YouTube player playlist.
And here's the result
I just basically have a camera pointed at the YouTube player screen and then mapped out the UVs for each TV to show a different section of the screen.
Is it a known bug that Input events don't run when the user has their VRC quick menu open?
i thought that was normal?
Doesn’t it block your inputs anyway? If you move it will close
I mean if you release your grip, InputGrab doesn't run
That's pretty dang important if you're programming things to happen based off that and simply opening your quick menu completely circumvents it huh
I'd 100% call that a bug even
Yeah that sounds like a bug. At the very least opening a menu should release the grip
Report it on canny?
how to disable (close) UdonGraph welcome screen
so i can work with my UdonGraph normally
any suggestion?
yes goto an udongrapth behavior in the inspector and click open graph
are teleports currently teleporting to spawn on the 2019 unity version? been having issues and the scripts work on 2018 but not in OB
It's not a bug, no inputs are allowed to be processed while the menus are open, for security.
Teleport is working for me in OB, yes
how does graph look? maybe somethings changed and im not seeing it
i totally did not just close the project that had the teleport script in it
:( okay
@cold raft
where exactly i can find open UdonGraph?
btw if this error log mean something to you
here:
BestHTTP.HTTPRequest/<>c__DisplayClass237_0:<SendHeaders>b__0 (string,System.Collections.Generic.List`1<string>)
BestHTTP.HTTPRequest:EnumerateHeaders (BestHTTP.OnHeaderEnumerationDelegate,bool)
BestHTTP.HTTPRequest:SendHeaders (System.IO.Stream)
BestHTTP.HTTPRequest:SendOutTo (System.IO.Stream)
BestHTTP.HTTPConnection:ThreadFunc ()
BestHTTP.PlatformSupport.Threading.ThreadedRunner/<>c__DisplayClass4_0:<RunLongLiving>b__0 (object)
System.Threading.ThreadHelper:ThreadStart (object)
You need to create an Udon Graph Program before you can open it, or choose an UdonBehaviour that already has a program on it. If you're just getting started, I recommend you check out these pages:
https://docs.vrchat.com/docs/using-build-test
https://docs.vrchat.com/docs/udon-node-graph
https://docs.vrchat.com/docs/udon-example-scene
yes click on that new program button
@floral dove
oh so i need to open UdonGraph tab first
and then to open in inspector
ok got it
ty 👍
if you don't have an UdonGraph tab open, clicking 'Open Udon Graph' will create/open the tab for you. The issue is you first need to create a graph to open.
@floral dove
ah what can i say...
i was so stupid
because i didn't see on right side the name of the button
because i didn't expanded inspector menu to the left side
sorry for all this nonsense i cause 😒
Np- we're all at different stages of our learning
Has someone already conducted a test, on how heavy SendCustomEventDelayed() is? I want a event to be fired every <1s, based on if a flag is set. Is it better to use Update(), checking a time variable, or queuing the event every time with SendCustomEventDelayed()?
it's definitely faster to use the delayed event because that runs outside of udon
Perfect, thanks!
It says I'm not using the right unity version for the sdk even though I'm using version 2019.4.28 for both unity and the sdk. It says I need to use unity ver 2018.4.20.
yes - that's listed as a known issue - that will go away when we release 2019 as the main version. Also, windows-shift-s will let you easily take a screenshot of your desktop 😉
sounds like vrworld tool kit time or check console or just. dont do build and test. or you might be using the wrong vrchat all together
Does the OnPlayerLeft event fire before or after the player leaves?
And would the leaving player still own objects when the event is triggered?
What's vrworld toolkit time?
did you follow all the instructions here? Make especially sure your VRChat path is set up in your settings.
https://docs.vrchat.com/docs/using-build-test
if all that is correct, you likely have errors when you build - check your console.
It’s triggered when your client realizes someone has left. Which might be in a completely different orders of events for other people.
Ie: when you join, you also get a join event for every other player already in the room.
Looking for some help on how to trigger the "trigger" parameter. I see a lot of methods online using bool but I'm looking for an interact to simply trigger my parameter.
animator set trigger
Trying to keep a VRCPlayerApi array updated as people leave and enter a world, but it doesn't seem to update after it's called the first time. Any idea what i'm missing?
the script is probably crashing
doing an equality check on a playerapi that has left will still return true. You need to instead use utilities.isvalid for such a situation
however, for that specific use case you don't even need to do anything like that yourself. Just run playerapi.getplayers once onplayerjoin and it will automatically populate the array
then you don't need to remove them from the array because every time you try to access it, just use utilities.isvalid and that will exclude players that have left
Thanks for the help!
This was a little bit of a test run, but the real use case will have only a portion of the players in the array at a time, and I want to grab and remove them at will
I would recommend having one big array of all the players and then a secondary array where you separate them out individually. This is because the getplayers function is relatively expensive as it doesn't just access an array, it fill the array up. So you shouldn't just casually use it every time you want to access all the players, especially inside a for loop
Would make a lot of sense, Thanks for the tip 🙂
I just edited it as i had tried previously, but this causes it to crash on the second int of the for loop
oh, and here is the other bit just to be sure
it's a bit confusing, but you don't want to use playerapi.isvalid. You need utilities.isvalid
playerapi.isvalid is accessing a property on the playerapi, so if it's null as is the case of an unfilled array, then it will crash. It will only work if it's a playerapi that you knew used to be valid but isn't any longer because they left
hmmm... would i also want to use utilities.isvalid if I was checking to see if say a gameobject array was missing a spot too?
No, that's not necessary
However utilities.isvalid is slightly more convenient in graphs since it combines 3 nodes into one. So you may still use it for that reason
Ah, okay.
Just checked it, but it doesn't seem to be updating with the new instances. any more ideas?
using cyanemu, errors do pop up...
Don't run getplayers in the for loop. Just run it onplayerjoined
ummm... how would that look in the graph? should i make a variable for the 'get players' to store it in?
Yeah, exactly
Click on the errors to see what they are
The important part is that it's trying to access a gameobject array and the object reference was not set to an instance of an object
Make sure that your gameobject array has exactly the same number of objects as max players and all the objects are valid
They are the same, even tried making the max lower to no avail
perhaps it has something to do with one of the earlier error messages
Add a debug log of the current value of intty and then the length of the gameobject array
It seems like the graph is been called multiple times...
Yes, every time a player joins
4 times though?
It's inside a for loop
It only runs twice
The second is when it goes back to 0
Something appears to be clearing the gameobject array. Do you have any other code anywhere else?
that it! each of the cubes had the same script on them... ouch
Got it! script works! Thanks for all the help! Wouldn't have figured out half of that 🙂
does anyone know a way to learn quickly the basics and some more advanced stuffs ? the tutorials on yt are good but i don't understand 30% of it and I would like to do some stuffs that are pretty hard to do in the future , like assign a trigger box to the Back chest of all players
I recommend you read the docs in the following order (assuming no knowledge at all):
- https://docs.vrchat.com/docs/getting-started-with-udon
- https://docs.vrchat.com/docs/using-build-test
- https://docs.vrchat.com/docs/udon-node-graph
- https://docs.vrchat.com/docs/searching-for-nodes
- https://docs.vrchat.com/docs/udon-networking
- https://docs.vrchat.com/docs/debugging-udon-projects
Then go through the UdonExampleScene and docs to understand common approaches and patterns: https://docs.vrchat.com/docs/udon-example-scene
Is there anything like OnPlayerParticleCollision that checks if a Particle has collided with a GameObject?
yes, there is. It's named exactly that
oh wait, you're saying you want something that has similar functionality to OnPlayerParticleCollision, but not for players?
If so, then it's just OnParticleCollision
unlike OnPlayerParticleCollision, you can put that one on both a particle system or a collider. If you put it on a collider, it will give you a reference to whatever particle system hits it
I've been looking through the docs and I can't find this
depends what docs you're looking through. This is not a vrchat function, it is a unity function that vrchat exposes. You can read more about it here https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnParticleCollision.html
Figured it out, thank you!
Im having a slight meltdown in the brain thinking department:
Is there a way to make a set percent chance that goes up over time?
Example: A 1/10 chance for a function to occurs fails, and thus becomes a 1/9 chance
Okay, I have a script that is supposed to play a sound effect on particle collision. I think I have something wrong in the actual playback part, because when I use CyanEmu to force the collision event, nothing happens. Here is my script and setup:
sure - make an int variable that you use in a Random.Range(min,max) call. Subtract one from the int every time you call it (until it hits 0).
Hey, I've been working on a world that has AudioLink set up, but now I'm trying to add a canvas slider that changes the intensity of emissions in the world.
Judging by what came with AudioLink, seems like I'm going to need some Udon# scripts/noodles to handle the behavior.
I'm also hoping to have networking set up on this too, so it is server-side instead of only client-side.
I'm pretty new to Udon so if anyone knows of any tutorials or assets that can point me in the right direction, I'd really appreciate it.
Fantastic, Newer question though: is there a way to compare the numbers to check if a number was infact hit? (1/10 chance, it hits the 1/10 and activates a separate function)
Im basically asking for a budget "IfElse" lol.
so it does work
Also, ignore me, i found what i was looking for
Did you do int > 0 and Branch?
yep yep
Question: is there an elegant way in Udon to spawn an object that only the spawned can pickup? In the past SDK2, I would have a prefab without a pickup enabled, on spawn I change the prefab local to enable pickup then spawn, then change prefab to no pickup again. This would work but hoping there’s a more elegant stable method now.
spawned objects are local-only, so if that works for you, you can just use VRCInstantiate
Spawned objects are local only? I mean if I object sync them they won’t be, right?
I need the world to see the spawned object but only the spawning player to be able to pick it up
in that case, you'll need to use a vrcobjectpool. It will behave similar to instantiate, but instead of creating new objects it will enable them from a set of objects that already exist
once you have that set up, locking down who can pick it up is as easy as just enabling pickupable for the person that clicked spawn
But would that enable any future people that click spawn able to pick up all spawned objects?
Or will each be unique to the person who spawned it?
depends entirely on how you set it up. But probably not
when you call trytospawn on the objectpool, it gives you a reference to that gameobject. Then you just do getcomponent vrcpickup, pickup set pickupable
the one edge case you'd want to handle is if someone spawns an object, then despawns, then somebody else spawns it again. So you'd need to make sure the objects disable pickupable from the ondisable event
Okay I’m brand new to Udon so I’ll try to figure it out. There’s like 2 spawn tutorials on YouTube and both seem overly complicated for what needs to get done
ok, here's what you do for a basic pool:
add a vrcobjectpool to an empty gameobject
duplicate a prop a bunch of times
put all the props in the pool's list (you can do this all at once if you lock the inspector at the top right)
make an udonbehaviour and put it on some button object
add a public VRCObjectPool variable to that udonbehaviour
add an interact event, make it trigger networking.setowner with the networking.localplayer
then make it call vrcobjectpool.trytospawn and use the public pool variable that you added before
on the udonbehaviour, plug the pool into the public variable slot in the inspector
I’ll give that a try tonight, thanks. Question, is a pool limited to the number of pool items I create? I assume so
yes it is
K
So none of that will make it pickup able to just the spawned though it seems, right?
nah, start with getting a pool to work then you can add that
Kk
Thanks again. I don't see how a pool will benefit over just instancing an object, but I'll trust you
it's not entirely about benefits, it's just that SDK3 does not support synced instantiation
there is some minor advantages to memory usage, it's much more efficient. But if it was possible I would still suggest instantiating for a beginner because pools are more complicated and more limited.
So, bluntly, ive been at this for about three hours now resisting the urge to ask here:
How to i make a "start game" button. As in: I click a cube, the cube vanishes, and it starts either A: a global function of some kind that allows me to play an animation on a totally separate object, or B: Just plays the animation directly to the separate objects.
Im entirely new to UDON and to be honest worldmaking as a whole so do bare with my potential not-smarts.
you would need to have a reference to the animator and then all you have to do is call animator set trigger. Then the animator can have a trigger with the same name that is used as a condition in a transition to an animation
@grand temple should my pool be inactive when I build?
the pool itself should be active. The objects I think would get disabled by the pool so that probably doesn't matter
k, testing now
k, that works
that was very clean and easy to follow/understand so far
do you want to do trashcans or something?
So what is happening when it's SetOwner to me?
only the owner can spawn objects from a pool
it's just making me owner but anyone that picks it up becomes owner anywa, right?
picks up the spawned pickup I mean
you're setting the owner of the pool, not the object
oh
the object's owner will be determined by whoever picks it up, so no need to set it manually
right.
so now with this, I need to find a way to make the spawned pool object to only be pickupable by the person who spawned it
when you run trytospawn, it gives you a gameobject. So first thing is to check if that is valid with the utilities.isvalid node. Since this is a limited pool, it's possible that the pool is already completely taken. If that's the case, it will give you a null object and isvalid will catch that
if isvalid gives you true, you can continue on and run getcomponent on that object with the vrcpickup type
once you have the vrcpickup, all you do is set pickupable to true
yes, all code in udon is local by default. It will only affect other players if you explicitly tell it to, like by sending a network event or setting a synced variable (which is what the pool is doing behind the scenes)
unless of course there's an event like onplayertriggerenter, which everyone sees. Then the code inside that would run for everyone, but not because it's inherently synced just because they're all experiencing the same thing
interact however is a local event, so this is all you
okay so my objects in the pool dont need their own objectSync added to them or anything as long as it's in the pool
no, the pool handles enabling/disabling but the objects inside still need to do their own position syncing so you would need objectsync for that
oh okay
K, I'm a bit lost on the Is Valid. I have that in on my TryToSpawn. Then from True you said I can getcomponent on that object. but how will I know which of the pool objects it is?
you can pull it out multiple times and reuse it
While im here i guess, Would this system work? It doesnt do anything in particular at the moment but is supposed to replicate Russian roulette more or less.
1/6 chance, if the 1/6 fails it shortens down to 1/5 chance and so on. If it passes, resets to 1/6.
I don't think compareto is doing what you think it does, especially to a bool
what do you want it to do?
Ok. lets go step by step.
RevolverChances_1 is set to a value of 6.
Range will pick a number between 1 and RevolverChances (I'll call it RC for now)
That number gets checked to see if its greater than 1. This gets compared to the yes or no values.
If yes, it would output a 1 (correct me if im wrong), which i can send to the subtraction to lower the Number for RC (Thus making it a 1/5 rather than 1/6)
If No, The output would be a 0 (Again, correct me if im wrong).
This is where things get messy cause im not exactly the smartest. If it passes the "No, its not greater than 1" test, then it resets the value of RC back to 6. (Reset_1's value is set to 6 as well, cause again, not smart.)
ok I guess compareto is doing what you expect but that is a little weird to do it in that way
I'm still stuck on the Is Valid - but I'll mess with it some more to figure out - thanks again for the help
True but i dont exactly know of a better way. Glad that means it technically works for what i want it to do then
I'd recommend instead plugging the bool that you get from the the greaterthan into a branch. That will split up the flow so you can do two completely different things depending on what the outcome is
I'll be totally honest i wasnt even aware that was a tool lol.
I'll rewrite it tomorrow since its currently 4 am and as much as i do have an idea of how to make it probably better with the branch function i really cant be bothered rn lol
Rewriting it also gives me a chance to add another function in RR, which is to spin the cylinder, which technically resets the chances to 1/6
lol programming until 4am, you're doing it right
How do you join a public server?
You mean a world in VRChat that's public?
Yes
Hey y'all, tad bit confused. I have a bunch of local only object with 0 networking stuff happening in them and I'm scrolling through my logs to find a massive amount of ownership transfer logs regarding them
Does network ownership get applied to everything on scene load up even if the object itself isn't actually networked?
Sorry for not responding, got sidetracked /o/
At the bottom of a world page itll show you the public instances of it, if there are any. Just select one.
Yes - every object with an UdonBehaviour is assigned a Network ID even if it doesn't have synced variables
oof okay
Am i doing something wrong with this script that attempts to destroy GameObjects that enter a trigger? The log activates but the object remains intact. Tried searching for answers and I couldn't find anything 🤔 .
if you can re-use them you might want to return them to a pool instead
I'm just starting out and id like to get to that, but it would be good to know why something simple like this doesn't work :S
(nvm worked it out, turns out there's two types of destroy and only one will apply locally? shrug)
how do I export a udon graph to a string that others can copy-paste into their graph to import?
wdym?
like the .asset?
or like specific nodes
sometimes when I ask for help here some people have linked a string that I can import and it loads the graph on my side
You just select the nodes want to copy and either control c or right click > copy
good stuff, thanks
Hey everyone, Im brand new to making VRchat levels, but have experience in game dev when it comes to environments and modeling. I was trying to block out my level, and was wondering how to get characters to sit cross-legged on a floor pillow vs the standard sitting position. I replaced the mesh on the Udon chair prefab to the one I wanted, just not sure how to change how the character sits when it interacts with the prefab
Sorry if this is the wrong channel, if it is, Ill post it in the correct one once I know which one that is
i might be wrong but i believe theres a "enterance" animation on the vrc station scrip where you can add a criss cross animation on
I don't see anything about an animation..
not the graph. the vrc_station
oops. My bad.
I rewrote my code from last night and somehow i think i made it messier. Can someone confirm for me that this would infact do as i wish it to do?
(Check for a 1/6 chance, then if it fails lower the chance to 1/5 and so on. Resets to 1/6 when passed.)
I do see a slot for an animation controller which is currently blank. Is it safe to assume Ill need to create a controller, add a new sitting animation to it, and then plug it into the VRC Station's animation controller?
That would make sense. Im fairly certain theres already a VRC controller for seats somewhere in the VRCSDK examples
There are, but it looks like just two different poses for default sitting positions. Ill take a look through the rest of the animations, if there is one, Ill duplicate an existing controller and add that animation to it, or make a new animation. Thanks for the help you two!
You can overwrite the sitting positions directly with your own sitting animation. I'd recommend duplicating the controller anyway either way lol.
haha yea. Wouldnt want to screw up the originals 😅
So to create this new animation I should probably download the avatar SDK, correct?
Just so I have the same character rig as the rest
Not sure on that one
You should probably just need world SDK
since the rigs are the same either way more or less
So I tossed the new animation controller containing the cross leg animation pose in the Animation Controller slot in the VRC Station script of the chair, but every time I build to test, it keeps detaching it from the script 🤔
I started my vrchat in debugging mode by adding --enable-debug-gui in the launch options and need to copy some numbers my world puts out in the console, is there any way I can select it to copy it?
You cant. At least not in the console. You can try to find that line in the Log which is located at...
anything written in there will be in your debugs log
Do you remember the command for the logs lol?
im pretty sure its written in there by default. weather thats on or not
I tried searching for the word log in the vrchat game folder with no results...
in appdata?
should be
its in %userprofile%\AppData\LocalLow\VRChat\vrchat
yeah I found it but there's only logs from yesterday there for some reason
not from my current session
is it because of the debugging mode?
nvm found it, thanks
Hi hi. I was wondering if anyone else is having issues with GetPlayerTag? Works with CyanEmu and in Unity but doesn't work when actually in VRChat. Thank you in advance!
K, round 2 of trying to figure this out: So I need help with setting my SpawnedSphere to pickupable. Not sure if I have this structured right but it's not working.
"pickupable" is unchecked on the spawned item by default. So trying to turn that on when it spawns it
Well first thing I spot, you got to tie the gameobject from try to spawn to is valid, and you should probably check isvalid before setting ownership
And your variable spawned sphere is not getting set, you should connect the same gameobject from try to spawn also to the get component
Than it should work
that object from TryToSpawn is a pool though, there's no pickup component in the pool itself, only the pool children
Try To Spawn is done on an instance of VRCObject pool, the value that gets out of it is a single object from the pool
So I assume that is you sphere
yeah
Do that sphere does it have a pickup on it?
It has a pickup script, but "pickupable" is unckecked. If I have it checked, it spawns it and I can pick it up just fine
but I want it unchecked by default and only enable the pickup for the person who spawned it form the pool
Ah I see..
🤔
Well that's correct than right? There is no networking involved here so it all runs locally
I am not 100% if pickups synch there pickupable state I would assume not
not sure if its synced but either way it's not activating it
Can you show what you made of it
oh, I kind of reverted back to where I was to start so no real change
I did notice there are two VRCPickup Types though...
VRC_Pickup Type and VRCPickup Type
I tried both and no results
I really just think my IsValid is not firing properly
I did try one other thing that I was sure was gonna work...
I dragged the Pickup component straight from inspector into the graph
and it made that new node
but it still didnt work
I just did one other test where I made a separate button with just those two nodes which should enable the pickupable to that object and that's not working either. So now I'm wondering if that Set Pickupable is working as it should be...
You are doing an Is Valid check against nothing?
It will always return false
I thought that was checking if there's still pool items (I'm new to Udon)
okay, so I can go from TryToSpawn to Set Pickupable?
Yes
awesome
okay, so my next test to simplify things is to see if Set pickupable is working and my smaller test is telling me it's not
this is my test:
I have a capsule with a pickup script. I unchecked pickupable.
I made a new button that on interact, set pickupable on that capsule pickup
and that's not enabling it
I know there's been funky things with "pickupable" in SDK2, not sure if it's still not a reliable checkbox or if I'm just not using it properly
That looks right though, right?
Sure
But if you have that on a pickupable object it might override the interact event
no, that's just a separate button that should enable the pickupable of the capsule
nothing fancy about it. but it's not working
@daring vector @slim hound you absolutely need isvalid because if the pool is all taken up it will give you null. Also, you have a whole bunch of stuff disconnected and not coming from anywhere.
First of all, the flow is all wrong. The white line specifies the order that things happen so you need to have it setowner first, then do trytospawn. You would do this by plugging the flow from the right side of setowner into the left side of trytospawn.
You want to plug in the pool's gameobject into the setowner, not the thing you get from trytospawn. This is because in order to spawn, you need to be the owner of the pool. The object you get from trying to spawn does not matter.
You never set spawnedsphere anywhere so trying to get it is just going to crash your script
You can drag out a variable multiple times, so you want the gameobject coming from trytospawn to go into both the isvalid and the getcomponent
You have to plug the getcomponent into the set pickupable. VRCPickup is the type you want.
Reading and working through this - one sec.
I know this isn't right because it's not working, but this is what I understood...
you still need to plug the gameobject from trytospawn into getcomponent
you can use it multiple times
It wouldnt let me
TryToSpawn GameObject to the instance slot of GetComponent, right?
get rid of the spawnedsphere first
woo!
now let me go back and re-read this and ask questions if I dont understand the flow
that's pretty much everything for this section
now you need to add an udonbehaviour on the objects that will handle despawning them and setting them back to pickupable false
do you want to have like trash cans or something?
no, I don't want this object to be despawned ever
what about when the person that spawned it leaves?
yeah, that would be a good reason
also, do you want to restrict it so you can only spawn one object?
no, so let me clarify the use case of this
This is to spawn a reward for the user. They spawn it when they complete a challenge (probably not more than 5 people will do this per session so wont be too many)
only the person that completes it can pick it up
show it off, so on
nobody else can touch it but everyone can see it
oh, that makes sense
then yeah I guess that's pretty much it
though if the instance goes long enough, you'll run out of trophies
but would be nice if it gets trashed when they leave... or not, that's not as important
yeah, I mean, I was thinking of having like 10 in the pool
yeah, all you have to do is add an udonbehaviour on all the objects that does
onownershiptransferred > set a variable called "lastKnownOwner"
onplayerleft > if the player given is the last known owner and I am the owner of the pool, return to pool
lastKnownOwner is the pool?
nah, just a playerapi variable that you make
so how would that OnPlayerLeft be structured to do that?
onplayerleft gives you a playerapi, you have a playerapi variable. Plug those into a system.object equality node. Then plug the result of that into a branch node. Branch will allow you to make stuff happen only if the bool that you get from the equality is true
this also needs a reference to the pool so make a public vrcobjectpool variable. You can plug that into a vrcobjectpool return node. And then you can just leave the obj slot of return empty because that will just reference itself automatically
I'm not clear on what the equality is doing
ah okay
So is this what I'm testing? Seeing if the player that left is = to the last known owner?
yep, now just plug the flow together from the onplayerleft to the branch. Currently it would do nothing because there is no flow
oh, the return is not correct. You need to plug the pool into the "instance" slot, that's referring to the pool itself
the obj slot is referring to the object you want to return
and currently the pool is a gameobject variable so that won't slot into there, you need to change it to a vrcobjectpool variable
k, you lost me there
you have a gameobject variable for the pool, change it to a vrcobjectpool variable
then slot that into the "instance" of the return node
and leave "obj" blank
I got that, but not sure how to change that, let me see
just delete the old pool variable and make a new one
I'm confused on how it's still referencing the pool at this point though
the pool variable needs to be public, which will make it show up in the inspector. so when you put this udonbehaviour on an object you'll need to plug the pool into it
got it, that makes sense. And I'm sure that's going to be one of the things I'm going to forget to do in the future 😄
The use text on a VRC PickUp: any good way to change that via the player using the item?
I really appreciate this 100%!! means a lot to me, honestly. Let me take a moment to take this all in and review this
sure, you can just set that with the VRCPickup Set UseText node
fantastic
So it's all working except for the onPlayerLeft. I tested with 2 players and when the player left, the object didnt return. I think it might be my OnOwnership Transferred
I just have it as a string variable and that doesnt seem right
yeah, you're not doing anything with the player that has left
and lastKnownOwner needs to be a playerapi
it's still a string
yeah that should do it
so before I test this, this brings up a question. Now that the item is returned to the pool when the user leaves, will it not continue to have the lastKnownOwner tag?
it will, but it will be disable so it doesn't matter
will that affect things if it becomes spawned again by a new user later?
no, because you'll only ever receive one OnPlayerLeft per player
Okay, still not working and I'm getting an udon error now
Specified cast is not valid
yeah that's definitely referring to plugging the playerapi into system.object equality
try unityengine.object equality instead
that doesnt seem to let me snap the VRCPlayerApi into it
Is it that though? I removed it and compiled and the error is still there
hm, that's odd. There is no playerapi equality, so you could try playerapi equals, but there's a difference between equals and equality and I'm a bit fuzzy on which one is needed here
That's an error with adding variables in Udon Graph
You need to restart the editor to fix it
restart and no error
You guys are Gods.
So I tested and still not going away. Could it be a local test issue?
because I'm using 2 local players?
Do you ever manually transfer ownership of the objects in your pool?
no, only the person who spawned it can pick it up so there's no ownsership transfer
did you pick it up before leaving?
yeah, since we're doing it this way you'll want to setowner of the object the pool gives you too
my other objects in the pool don't have the public pool variable even through I told the prefab to override all
prefabs can only maintain references internally. If it's to a reference outside the prefab, that won't be saved
but even then, prefabs and udon don't get along very well
If no other player can ever take ownership other than the person who spawned it you could just use OnOwnerShipTransferred to send it back to the pool
With a behavior on the pooled object itself
are you getting any udonbehaviour errors?
huh, I've never had that before
oh, something went wrong when you switched the pool from a string to a vrcobjectpool
it's probably remembering something old that no longer exists. Try renaming it to something different
If the error hasn't changed that probably isn't possible
The invalid cast error makes udon graph completely unusable
do you know how to reproduce it reliably? I can't get it to happen by just naming a new variable the same as an old deleted variable
I only ever got the error when adding variables by dragging and dropping them into the graph
I know it never occurred if I had just opened the udon graph program directly
No more error when I made the pool a new name, but still not working. I'm going to try having it just return it on ownershiptransfer
I think that's an elegant solution and makes sense
you'll have to add a timer that makes it not return if it's been less than a second since being spawned
you can do that by just setting a float onenable
and use time.timesincelevelload
Shouldn't need to do that if you check if ownership is going to the master and only returning if so
Also the reason it wouldn't be working is you are storing last known owner as the new owner
yeah, it's being returned the second I touch it for the first time lol
because it's changing ownership to me
Try do OnOwnershipTransferred then check if it was transferred to the master and if so then return
Yeah but from the Ownership Transferred event plug the VRCPlayerApi into the Get isMaster
makes sense
Again, GODS!
works
@grand temple @slim hound Thank you so much
I appreciate the guidance and it all makes sense and is easy to follow. Learning more of this as I go.
Any idea why this graph isn't setting the boolean back to false once it hits 10 seconds?
i have a proper timer that does work in the behavior, that's how it enters this condition, but for some reason it'll make the boolean true, but never set it back to false
Everything going along the flow like that happens instantly
thats why i have the greater than condition- oh wait i see
I see you have ondeserialization and onplayerjoined but it's really hard to tell how those are connected when everything is squashed together like thet
yeah im gonna be removing one once i get to testing in game, but now i see why it isn't working lmao, i just need to put my false statement in a better location
you could just use a sendcustomeventdelayed
u rite
I think i refined my code from yesterday. It now uses a branch and custom events to tell things when to fire off in order.
What im having issues with now is setting custom events for a few specific things
I’m away from my desk now but just had a thought. Do pool spawned items have a pre set action when they fall off the world? Or do I have to set that?
the pool doesn't care, but if you have objectsync on them then they will be respawned
you can change this in the scene descriptor
1: Im trying to make it so that its a single action revolver: You have to pull the hammer back (Use1), and then pull the trigger.
2: I also need to make it so that it will fire a bullet if it hits the "false" on the GreaterThan Check (preferably just play the animation thats set on a bool value currently)
Respawn being where it spawned from or respawn back into the pool?
it's original position
K perfect
Currently, the absolute nightmare of code i have right now is this:
if this is on a pickup, just use pickupusedown. InputUse will trigger whether or not you're holding it. It will also trigger for both hands and for both down and up
Got it.
and any ideas on how to make it single action? (Pull hammer on one use, pull trigger on second, resets to the start)
keep track of the state and have branches based on what state it's in
Got it. lemme think of a way through that quickly.
I feel like I'm missing something basic, but any idea why this is throwing out errors?
For all the udonbehaviour methods like onplayerjoined, you need to do 'private override void OnPlayerJoined'
Weird "W" appearing on my "Sit" text. I'm not concerned for now, just wondering why this is happening,
yup.. something basic. perhaps. Unfortunately, it didn't like me adding the override... anything else i've missed?
is it just meant to be public?
Eh maybe I got the order wrong. Delete those entirely and starting typing 'override onplayer...' and your autocomplete should make it correct