#udon-general
59 messages ยท Page 101 of 1
i don't know how to read udon yet. where in your code is it checking if the player being checked is the player who left the collider?
it is the method, OnPlayerTriggerExit(player)
it comes with the player that left the box collider
i could be misreading what it's doing but it seems to me you would want an if else with the triggering player in the if side doing nothing and the other players in the else side doing the teleporting?
the problem is more like this one
if (players[i] != null && players[i] == Networking.LocalPlayer) SendCustomEventDelayedFrames("OnGameFinishTeleport", 1);
since I remove the player from the array when they left
it seems like that it doesn't enter in that state
at all
You could just teleport LocalPlayer to the player who exited the trigger. Do you need extra condition?
i'm wondering are you trying to get the pool down to 1 or detect the first one to leave? on thinking about it i assume the latter otherwise it seems pointless to manipulate the array.
the pool in the end will have only 1 player, and I want it to teleport him away
if (players[i] != null) player.TeleportTo(respawnPoint.position, respawnPoint.rotation);
I think this should work maybe
Teleporting works only on LocalPlayer btw
ahh so a last man standing kind of situation. yeah gonna want to shrink the array then...can you output the contents of the variable to some kind of dev console to confirm the array slot and the variable match?
that's the only reason i could think that it's not properly nulling it out.
I think i get the array empty before it happen since
Ok I see. If you have an array of player who is in the trigger, you can use System.Array.IndexOf method to get an index of player containing in the array. If player doesn't exists in the array, the index will be -1
ye and I think the array is like empty in that moment
An exception occurred during EXTERN to 'VRCSDKBaseVRCPlayerApi.__TeleportTo__UnityEngineVector3_UnityEngineQuaternion__SystemVoid'.
mhm
Should see detail on another line too
Runtime error detected, but the client has not been launched with '--enable-udon-debug-logging' so the error cannot be traced. Add the argument to your client startup and try again.
[UdonBehaviour] An exception occurred during Udon execution, this UdonBehaviour will be halted.
VRC.Udon.VM.UdonVMException: An exception occurred in an UdonVM, execution will be halted. ---> VRC.Udon.VM.UdonVMException: An exception occurred during EXTERN to 'VRCSDKBaseVRCPlayerApi.__TeleportTo__UnityEngineVector3_UnityEngineQuaternion__SystemVoid'. ---> System.NullReferenceException: Object reference not set to an instance of an object.
this is the ful
full*
Whatever calling TeleportTo doesn't have value assigned
oo i'm prolly gonna wanna figure out where to add that command to.
question. in udon are arrays' .length value or whatever it is in udon dependant on FILLED slots or LAST filled slot? like if i have an array Fu[] where I've put "Bar" in slot 55 but haven't put anything else in it would it be listed as a size of 55 or of 1?
ok that error
was something else, a little mistake that I did while I was changing something
The .Length is a defined array length regardless of members are assigned or not
it doesn't matter with the teleport at the end
...so it would show as 55 then?
Yes
damn...so then for my use case i think i'll hafta itterate through the array's 10 possible slots checking if they are null while incrementing a variable then use that in place of the length...
it would be nice to use Lists and LinQ but I guess we can't
i seem to recall some methodology in c where you could check the length of an array both ways...don't recall how that worked but it'd be cool if every language had it. ๐
hrm maybe that was sizeof vs length? i can't remember what either does honestly...gah 10 years without using a language is seriously detrimental...
That's the same as .Length
erm? i'm either super confused or i think you misread what i said since from what you said before .Length has one type of output and i was describing remembering c having 2 types of output.
What could be the second type? Like counting member that isn't null?
There isn't any function that does that out of box either in C or C++. You still need to add condition and filter the non-null member and count it.
hrm musta had a lib that i always used that had that functionality then...
Could be that
i remember using that functionality for a card game simulator i made. i could remove cards from teh deck by nulling them out and then the deck count just knew without any loops(at least not in my main code) how big the deck still was...
i'm guessing the library basically just used a loop to check all the slots though.
Internally it is. It's just easier just calling one function.
what's the purpose of the teleporting? is it like moving on tot he next round?
i'm confused then why it's bad that everyone gets teleported...
no it's bad that who is still in
What happens if the last person also goes outside the collider?
doesn't get teleported
Maybe your count just start at 0?
ye it start at 0
So you have to do count < 1
mhm
let's tr
try
it didn't work
the last person is still in and the game didn't got
resetted either this time
The last player will never leave, so it never triggers OnTriggerExit.
ok these variables and arrays are confusing me...so when you interact with an object it controls variable data in that script...then to access that variable data you peak at it from another script...which makes it seem SUPER complicated how i'm supposed to have a bunch of "join game" buttons around my table that store the player id of the person sitting at that spot on the table...
how can I make him leave when the game end?
it's like the solution is close but maybe i'm just tired XD
that sound like there is alot work to do, something similar to the billiards tables?
Scratch my last comment, I was wrong. It will trigger for the other players, so your code should work.
i guess that each join game button stores to a variable not an array, then the "start game" button peaks at all those scripts to build an array for it's own usage then all the other scripts peak at that button's script in turn?
Maybe the issue is somewhere else in the code, for example when you put the players into the array.
The player instances are still different, even if you use Build and Test.
I see
i'm wanting to do something kinda like that i guess. i'm making resistance (the board game) and rather than having to shuffle cards and then secretly hand them out and have everyone secretly check them i figured i could automate it sorta like how the amongus server does.
there is something wrong in that way of saving the players in the array?๐ค
That should work. Are you displaying the counter? If not, you could try doing that in the canvas, maybe you see the issue this way.
well like the way i'd do it anywhere else there would be an array that just exists that i could put data into from anywhere else int he program. so to me it's very weird that i have to constantly be cross referencing scripts...
"when in doubt spam the heck outa debug messages!" ๐
Yeah, debug.log it.
You should be able to press "RShift + Backtick + 3" to see them. Or enable logging in UdonSharp if it's not on.
i usually prefer runtime debugging. instead of having a log somewhere instead my code is displaying all the debug info real time alongside what it's supposed to show. that way i can track every variable at every step to make sure things are changing and getting set the way i expect.
that's probabily the case, that logging in udonsharp is not on
how can I turn it on?
Project Settings and then UdonSharp, I think it's called Listen to Client Exceptions
it seem it was already on, time to test again then
I'd recommend debug.log(counter) them. Then just "RShift + Backtick + 3" while in Build and Test.
Or make the canvas, I assume you want to have some kind of display for players anyway.
guess so i'll make the canvas
i guess its somewhat udon related. how can i make pickup objects 2 handed? i want that if you first pick it up, its one handed but then you can grab it again to make it 2 handed
Unless there is a solution for VRC somewhere out there, you will have to code that yourself.
It shouldn't be too awfully difficult though, just requires some rotation math.
i imagine there's code to help figure it out int eh pool prefab.
oh well, ill try but im a bit dumb
Try looking for tutorials for regular VR stuff, I'm sure someone must've made one for two handed pickups. You just need to take out the math, and ignore all the SDK specific code.
Took me a bit what you meant by pool.
Yeah, the pool prefab might have some code for holding the stick with two hands, you could look into that too.
it def does. though the way the pool tables work is a bit unique. once you are holding the que stick there's a glowing bit that you can grab and that's the second handhold. it then pivots around that handhold while the other hand controls distance and is where you derive that pivot from.
ok i must be dumb...how do i store what player pressed the "join game" button?
I'm assuming join game event is locally fired? Then you can just use the local player.
i guess? it's an interactive object like used for toggles and the like.
i hit space and searched for local and nothign came up.
oh found it hidden under networking. would be nice if the search could search inside submenus...
You can use 'tab' instead of 'space' to search through submenus, too
it's slower, which is why we default to filtering by class first with space
what's the datatype of LocalPlayer? i thought it'd be an int but trying to store that in an int didn't work.
It's a "VRCPlayerApi" object
i see...
that object does have an int, I think it's playerId
here's more on that class: https://docs.vrchat.com/docs/players
You can interact with Players in your world through the VRCPlayerApi. Each Player has a VRCPlayerApi Object, and your world fires the OnPlayerJoined / OnPlayerLeft events on any UdonBehaviours that listen for them when a player joins or leaves. This page includes info on using some general nodes. Si...
k so in the button's script i'll store that to a variable. then in the "start game" button i'll have an array that looks at all the buttons to get the players that pressed each and get them tied to the right part of the table?
and i'm guessing i'll wanna do a network event so all the data can be colated onto one user...
just realized...this is just going to make it look like the local player is sitting at all of the active table spots...i need to grab it before sending the network event then figure out how to transmit the playerapi right?
As stated it's being moved by its translate function (Transform. Translate (Vector3)). The object itself i tried as part of both the environment layer and interactive layer.
The collider is also very large on the object so it spends a good time intersecting erroneously before fully breaching the wall, due to the slow movement speed.
I'm thinking that translate might not account for physics, but I'm not sure what else to move it with by a set amount.
I'll translate your graph as best I can:
- When the local player "Interacts" with this UdonBehaviour, send a NetworkEvent to everyone currently in the world to run the event "ToggleTarget"
- Every player currently in the world will run "ToggleTarget" locally, which will set their 'PlayerAPI' variable to their own PlayerApi object.
- Then each player currently in the world will toggle the target GameObject's active state to the opposite of whatever it currently is.
If that's not what you want to do, could you explain what you would like to have happen?
Yeah, it just moves the object directly and ignores physics. You'd need to do your movement via a rigidbody or calculate the collision yourself.
You could try rigidbody.velocity and feed it your vector3 movement.
Would velocity continue though when input ceases? Or will it have momentum? I was thinking about testing the same but that's my big concern.
If you set velocity only once, then it will keep its momentum. That might not necessarily be a problem though.
What specifically are you moving with Translate?
Wheelchair. Was grabbing user input and applying it to "velocity" & "rotation" values, then on Late Update I would multiply those values by Delta Time to move & rotate the chair. Works great if you don't consider the whole clipping through geometry thing.
I see, so the one sitting is controlling it? You can just apply that velocity and rotation to the rigidbody and it should be fine. If you do it every frame, then as soon as the player stops giving input, the velocity will be 0.
Yes, and Noted.
While you're here: Is there any special logic a VRCStation with an Udon Behavior needs? I was having trouble getting this working for over an hour the other night, and the only solutions appeared to be either removing the udon controller, or adding this bit of logic:
I'm still new to some of this, so I'm worried this may be incorrect. (It does look similar to an example program though.)
how does this compare to the example program that shows how to use a station in the UdonExampleScene?
someone can help me with this? I want the player to drop items if he is using some
but ofcourse they can be null
it goes on error on line 76 saying it is null
how can I avoid that error?
I'd have to open up the example scene to be sure, but I looked back over the UdonProgramSources directory under Examples, and found a Station related program (I overlooked) which is nearly identical to depicted; the only difference is its using UseAttachedStation and I'm using UseStation and a station variable.
Though the docs don't really make it clear that station interaction is disabled with Udon Behaviors, which is why I am confused.
First, I recommend you add a Debug.Log statement between the Interact and the UseStation to ensure that the event is firing
Yeah, the example is what I used to see how to do it. I don't remember how the station exactly work of the top of my head.
Can debug information even be viewed on Quest? I don't have a PC to test with. I usually have a friend test my world after the Quest end is stable.
And after adding the behavior, it works, to be clear. It wasn't working without handling Interact.
You could have the interact change the value of a text field instead of writing a log. The main things is to ensure that the "Interact" event is running. How do you develop without a PC?
I have a Mac.
The docs for VRC_Station make no mention of Udon Behavior requiring additional setup, so I was confused as to why the station was disabled with an Udon Behavior attached. But looking over the example, that seems to be by design.
Ah, ok. You could use ClientSim to test in the Editor for faster iteration in the future: https://clientsim.docs.vrchat.com/ But to solve this particular issue, you can have the Interact do anything else which will be visible for you - like changing a text field, or toggling another object on/off.
If the station works now, is there a reason to test the interact?
I feel like that question is self-explanatory. If you don't have trouble then you probably don't need to test it.
I have a question about VRCObjectSync. It doesn't seem to sync between players when I disable the object during Start.
What could the reason be for that? I could swear it didn't do it before.
Oh, there's not - I think I misunderstood and thought that you couldn't get it working.
Re-reading your original post, it sounds like you're asking if a VRCStation needs an UdonBehaviour in order to function. If that is your question, the answer is yes.
Would it be rude to ask why? And why that is seemingly undocumented? I understand that the examples use this, but at the very least, the document page for VRC_Station makes no mention of Udon.
Thank you for pointing me to client sim though; had no idea that was a thing. Will definitely give that a go.
I agree that the documentation for Stations should be updated to explain how to use them better.
So I tried delaying the disabling by a few seconds and now the VRCObjectSync works. Odd, wonder why that happens.
like the teleport one
write something a bit ugly but I don't have really other idea for making people drop things
and this one work
๐ฉ
you can use player.GetPickupInHand(VRC_Pickup.PickupHand.Left) and player.GetPickupInHand(VRC_Pickup.PickupHand.Right)
tried, it goes in exception if that hand is not holding anything
then check it with utilities.isvalid
as I wrote here it gone in exception in the first line, there is a way to check is valid before
even taking the object?
i'll look into it anyway
yeah, only do anything with it if it's valid
if (Utilities.IsValid(RightPickup))
{
RightPickup.Drop();
}```
wait a moment
oh god
it is the local player that make it fail?
in my case i mean ofcourse
since I was not using the local one
well it's a function you call on the player
so yeah if the player is not valid that would break too
I don't know if getpickupinhand works on remote players but it at least shouldn't crash as long as the player is valid
yep
I would not recommend using player.isvalid
use utilities.isvalid(player)
player.isvalid will only catch a very unique situation where the player used to be valid but has now left the instance. if the player was simply never valid, like if it was straight up null, then player.isvalid will crash the behaviour
Is there documentation or guidance on how to upgrade an existing project? The instructions say to use the package format versions of the SDKs, but it seems to be colliding with the pre-installed Worlds SDK. (My console had a lot of errors suddenly during import.)
Sure, that's covered here: https://vcc.docs.vrchat.com/vpm/migrating
However, if you can wait an hour or two, we're about to drop a new version of the Creator Companion with some big changes and upgrades so it's worth holding off for a little bit. (New version will be announced in #creator-companion)
Haha no problem. There's just a new migration method in the new version, but it's even simpler so shouldn't be a big deal.
I winged it and treated it like the Avatar SDK during the betas:
- Put under source control
- Make a GIT commit
- Fire Sale: All SDKs must go
- Import the new SDKs and hope Unity doesn't crash
- Crash? Revert to commit.
that's some big brain work right there
I learned the hard way not to trust anything between Unity & VRC SDKs. So many animator properties, lost to the abyss.
It's big brain, it's messy, but I know nothing will be lost.
if you're doing a git commit first, then you can use the in-place migration rather than having an extra copy. We warn against doing that for people who don't have backups
In-place migration? If you mean importing the new SDK over the old SDK, that's exactly why I use GIT now.
It might be Mac related, but there's a 50/50 shot migration goes south for the winter.
Causing a bunch of errors related to math, causing the SDK control panel to break, etc.
That's why I started deleting the old SDK first.
And then Unity crashed and removed all SDK related properties from my project.
So now I use GIT to ensure that isn't permanent.
I mean the option in the Creator Companion to migrate from the legacy .unitypackage system to the new packages system. It offers you the option to migrate a copy or migrate in-place. We highly recommend migrating a copy unless you're 100% sure you have a backup of your project.
OOOoh I get you.
Is the creator companion out? I'm sorry if I'm out of the loop on things. I just look at the docs, which tend to fall behind.
It's currently in an Open Beta
I may hold off trying it for now. Unity did not like the package form of the SDK base.
(Complaints about lack of various types in System namespaces, such as "immutable")
Restarting it seems to be doing something.
after i drop a object with VRCPickup.Drop
there is a way to respawn it?
i mean how can I take the VRCSyncObject for respawning it?
You need to use the Creator Companion to install the new SDKs. Not sure how you pulled them in but if you did anything besides using the CreatorCompanion or adding the proper git URLs yourself then they will not work.
grab a reference to it before you drop it
I did the proper GIT URLs
It looks to be doing something now though.
I think it just had cached parts of the old SDK that hadn't yet refreshed.
It gave me some new prompts on relaunch.
Though my console is still filled with errors.
you mean I put the gameobject as var in the code, in the code from the gameobject I take out VRCPickup and VRCObjectSync?
Ok - I'd still recommend using the CreatorCompanion instead since that will actually remove the existing SDKs and add the new ones. But like I said, new version coming soon that switches from git to embedded packages so best to wait a few hours to a day at least.
Is there a link to the companion?
Sure, that sounds like it could work
Sure, it's on the page here: https://vrchat.com/home/download/sdk
now that I think about it, the object is thowable so, doing a box collider for the player
feels useless
Uh momo that's an EXE
I use Mac
Ah right. There is some preliminary support for Mac and Linux through the CLI: https://vcc.docs.vrchat.com/vpm/cli
I think I'll stick to the unitypackage version of the SDK for now and forgo the client sim.
I don't mind having to publish and test.
Beats headaches caused by upgrading SDKs.
Alrighty, I understand. Good luck with your project!
(I had 400+ errors with the GIT packages)
if I do a box collider, there is a way to write if the object goes outside of the box collider, respawn
?
that happens when you have both the unity package and the git installed
create a backup of your project and then remove all unity package sdk folders and then add the git urls
or just use the migrate button in the creator companion which does it for you
That's what I did.
did you try to migrate in the creator companion too?
We just established that the creator companion isn't readily available for Mac.
There's a CLI version, but that's a bit of a headache to go through the trouble for just to test my world in unity.
ooh yeah sorry didn't see it
I mean cli shouldn't be that hard right? You only have to add and then migrate
would probably just be like 2 commands
though I haven't used it yet
I'd have to install the .NET 6 SDK, and I've already spent a considerable amount of time already futzing with this. I also have limited drive space, and a lot of SDKs like .NET insist on being on the system drive as opposed to external.
ah ok understandable
So I'd rather just wait for now, maybe try it down the road.
just curious, why isn't the normal creator companion not for mac/linux? Isn't it made in unity? It has the unity crash handler in it's program folder
Yeah, OnTriggerExit, teleport to the location of the spawn object. https://www.youtube.com/watch?v=BheVIHD3Vrg
My old video for teleporting players in Udon is crap and outdated, so here we are with a brand new demo on teleporting players in VRChat.
I've had some technical problems with my avatar program, but I've swapped to VSeeFace for now and am using my new avatar.
Hope everyone enjoys!
----------------------------------------------------------------...
BTW there were errors when I messed up the first time and this happened, but not 400+ of them, and they were conflicting namespace errors.
When I deleted the old SDK first and then installed the GIT versions (after a git restore), it was complaining about basic classes and namespaces not being found in system classes.
I'm thinking the package versions might not be fully tested on Mac? Either that or something about my project structure and Unity's weird caching is causing me yet another issue.
that work for objects too? not just players'
?
did you install the base package aswell? The git packages are split into base, world and avatar and for worlds you need base and worlds and for avatars you need base and avatars
- The CreatorCompanion does a number of Windows-specific things like finding Unity Windows and bringing them to the foreground, etc.
- Windows is currently the preferred development platform for VRChat and the only platform that receives full support. We'll do our best not to break our SDK for Mac and Linux users, but we're concentrating our efforts on the vast majority of our creators who are using Windows.
Sorry for the trigger, OnTriggerExit should work, this video is what you need for object respawn https://www.youtube.com/watch?v=p6vtL_BRMEo
Here's a simple button script that respawns a sync object in the world. Use this to get back an object that someone has run off with or lost! This doesn't work for objects that don't have an object sync component on them, but if it does, it's super easy!
Hopefully this helps, and if you have an questions feel free to leave a comment! ^^
Creator Companion discussions are best held in #creator-companion, and you'll need to follow the instructions for your platform to get a project migrated to the new system.
if it's just that shouldn't it just be a few if statements to add mac & linux support? I understand that vrc only supports windows though but some people only own a quest & a mac I guess
Thank you. Wasn't sure if this was appropriate to continue here, but was a bit shy to ask.
thanks for the info i'll look into them now
i'm a bit confused about OnTriggerExit
there isn't any override of that one
you can also use cyanemu https://github.com/CyanLaser/CyanEmu btw, it's the unity package client sim is based on. It has slightly less features but it's still better than having to build & publish every time you want to test a small thing
Maybe? It should just be like the video has it but OnTriggerExit instead of Interact but I haven't done that sort of thing myself.
udonscript is failing to compile somewhere?
You might want to try removing that and see if you have any issues, at least it would narrow it down.
ok its def my chessboard
literally says
failed to compile after that error
now i have no chess
:C
I'm not familiar with that particular asset, but making sure Udon Sharp is installed would be the first thing and then just consult the documentation if there is any.
Ok
how do u split a vector into 3 floats
like UE BP lets u split a vector 3 to have 3 seprate pins for each value in a vector 3
how do u do that in udon
whats the setter called for it
vector3 set x
is it set
As I said in that message I want it to trnasmit the PlayerApi variable to everyone online (and to any new connectors the way i am with toggle states)
vrc pedestal isnโt click able
The VRCPlayerApi object cannot be synced across the network, so you'll need to try another approach like syncing the id. Why do you want everyone else to have the PlayerApi variable?
momo help :<
Try the one from the UdonExampleScene
Im trying the prefab one
when i say i want it synced i don't mean that object necissarily but some way of agregating the full list of players of have joined the game and at what table slot they did.
Are you running in Build & Test? Can you provide a few more details?
i imagine if i could even figure out how to transmit the id in the object then i could then look it up in the array function i create later.
Ok, you can assign someone as the 'owner' of all the information and update a playerId variable on them instead, always check with them for the logic of player-to-tableslot
In my world the pedestal isnโt intractable
...momo it's much appreciated that you are helping, however you are misunderstanding my struggle. honestly your suggestion here is something i already considered. my issue is that i have not found the graph entity i need to transmit anything other than event data. well that's the issue i have at this very moment...
your options for networking are Events or Synced Variables. Maybe this information will help: https://docs.vrchat.com/docs/udon-networking
The three main concepts used for networking in Udon are Variables, Events and Ownership. Variables are containers for values - like a number, a set of colors or a 3D position.Events are things that happen at a moment in time.Ownership is the system that decides which user can update a variable, whic...
compare the differences between the two for their Udon Programs and their variables in the inspector, as well as their layers and colliders.
... ok i'm so friggen dumb... i read that last night and couldn't figure out how to sync varaibles but you don't ever transmit it you just check synced...no idea how i overlooked that...must have been WAY to tired.
ok now the issue i've realized is if i'm going to be syncing an int instead...i need to find the graph entity that lets me grab that data out of the PlayerAPI entity.
basically the equive of varID = PlayerApi.ID i'm guessing.
hrm do they not have ids?
oh duh they probably do but not as a data piece but as their index in the array...so...i'm going to need to itterate through the array?
is there a way to get the direction a player is looking?
i could be very dumb but wouldn't GetRotation be that?
what outputs do you see on the node for the VRCPlayerApi object?
... and i just found get player ID... JFC..i swear i did a space, playerapi, id and nothing came up...
Yeah, it can be helpful to just lay down the object first so you can see its fields and their types
oh wait... is what i found...is that not right? cause i didn't find a dedicated VRCPlayerApi object.
That's correct, you'll need to feed a VRCPlayerApi instance into it to get the player id out
having this before the network event will do that though, no?
ok. so i have the join/leave button configured to store the user that clicks it. i'll need to also set it to have a way to null it out if the player leaves. then i need to create a similar button for taking hosting privileges, then i can use the host buttons to agregate all this data into something useable in the game...
ok something i'm confused about for the toggles it looks like using one script for the whole group works fine but it looks like when you go to peek at variables inside a script you can only do it from the overall script not from a specific instance of it...so should i be having a different script for every button in my script?
It seems velocity is not the thing I'm needing. The chair barely moves at all, and I also seem to get some "unspecified" behavior where it continues to drift slowly.
I am going to try something else though, and will report back if it works. If you or anyone else has any ideas on how to "translate" an object with physics, let me know.
It sounds like you might be applying deltaTime to it. If that's the case, try removing that. Rigidbodies run during FixedUpdate and don't require deltaTime, so the velocity might be too small to have much effect.
Oh I was. I didn't realize that, oops.
Do you know how to fix the object "bouncing" around, picking up momentum, etc.?
Nevermind, I think I understood "Freeze Rotation" lol.
So yea no removing delta time didn't seem to change it. I found a method that works though, it's just a few extra steps. (Using MovePosition and some math on the existing position)
Is there a way to trigger the VRC input window and in-game client's on screen keyboard (on Quest, particularly). I've seen some video players do this, but the built in example does not. I didn't change anything about the input window, functionally, yet click and nothing happens. It registers the selection, visually, but no input window appears.
I've seen worlds trigger the input window on video players, so surely I'm doing something wrong?
can someone verify if each button should have it's own script file instead of just using the same script file when i want to be able to use the variables for each button separately? I'd rather fix that before i get too deep in this.
I have a script that represents a button on the keypad. I just use a integer variable to tell my master script what digit they pressed and for reset or enter, I just use two bools isReset, isEnter
i'm not sure how i'd derive this with my graphs as they are set now. right now i just have the graph dragged onto 10 buttons and it does it's toggle stuff just fine but that's because i set the target toggle in the button's inspector not anywhere in the script...
I'm on the go but i reference my master script and call _ApplyDigit(int n) or if isReset, _OnReset(). And it goes on from there. My 1-9 and reset/enter is the same script behavior, just each button object has a instance of the script
i'm guessing if i am having the script get variables (like who pressed which button) then this instanced aproach might get trickier than just having separate script files?
my final usecase is that there will be 10 buttons to join the game, each of the up to 10 players will click a different join button and then the button will disapear from everyone preventing anyone else form joining the same number (until the player who already has it clicks the leave button or the host will probably have a force clear option for if someone d/cs) then i need to have an array of which players hit which join button so the right info shows to the spys vs the resistance.
Ok so a single script can achieve this. On interact, grab the vrc player's display name and store it in a variable so that button remembers the player.
Then you can .setactive the button behavior to false to hide it.
Oh and vrc object pool will help a lot since you're wanting to manage these buttons as a collection
- wouldn't player id be better than display name? 2) won't the second button pressed overwrite the stored value in the variable?
Player ID is fine, either or display names have to be unique.
And no. When you have a button hold an iantance of a script, it only affects itself. They don't share a same instance at all.
one question this gives me, is player id comperable with the index of the player in the world's players array?
ahh so then when another script looks at that variable you are able to tell it which instance of the script you want to peek at then?
Worlds player arrays? You have to build that yourself. You ultimately rely on the vrcplayerapi https://docs.vrchat.com/docs/getting-players
These nodes are useful for getting an individual Player, a group of them, or all of them. Networking.get LocalPlayer VRCPlayerApi The local player is the Player that this Udon script is currently running on-- alternately, the local player is you. It's very important to know yourself! GetPlayerCount ...
ahh i assumed somewhere the world was keeping an array with all the logged in players and their 3d location indexed most likely by order of join. and that you could then refference this array(actually assumed that's what vrcplayerapi was doing.
Exactly, you reference all buttons in another script and read its variables granted you made it public accessible
Yeah VRCPlayerApi[] is your gateway to all player and transform data that vrc permits you to interact with. Let me forward you something I do to track my players and their own data.
This. Sorry I can't express it in graph but I am using an object pool to hold objects that runs my player scripts that holds data about the player. Typically a copied object of vrcplayerapi.
You can do the same for a button, but you'd do it for interact and pull Networking.localowner vrcplayerapi object to your button.
I'm mobile right now so my example is approxinate. For your button graph, create a vrcplayerapi variable and player name. You can't sync vrcplayerapi object itself, so we will depend on the player name to be your key index.
On the button graph, on interact, take ownership of the object, set the vrcplayerapi with networking.localplayer and set your playername with .displayname from your vrcplayerapi object.
Now your button will remember the person who interacted with it, and you'll need to sync playername so others will see this reflection.
Now you're ready to call each button and enumerate its values.
I'm having an issue with Raycasting
I have my origin and direction determined by the head rotation of the player
but when using the debug draw rays I cant see them
i set the color and opacity
What's the state of struct support in U#? It seems to have let me create one but I can't do anything with it
You can't play videos in the inspector. you'll need to 'build and test' to test this
what error messages is it giving in game? (Rshift + ` + 3)
there is a way to change TextMeshPro Text in code? since I can't find TextMeshPro reference
nvm solved
how do I set a public UdonBehavior variable to another script? i cant drag anything into it unlike other public variables
do you know if theres a way to do that in the graph?
I'm sorry I don't know, I'm quite new so I didn't used a graph yet
ah alright, thanks for the help anyways!
yea, it should bring up a debug console. make sure you are using the Right Shift + BackTick + 3, and not any other keys
how i detect analog button pressss
is there a way to open multiple graphs?
Is there anything about axis events for input nodes? I can't look because I'm on the go but see if there is an event for axis key press
Not that I know of, would be a nice feature
of course not
i feel like the very most frustrating thing about unity is the way that it seems like no 2 of the same thing can ever be open at once...which makes copying bits from one thing to another rather painful.
I need a way to take a Euler rotation value and turn it into Direction value
convert it to a quaternion then multiply that quaternion by vector3.forward
so take the quaternion x, y, and z values and multiply each of them then construct a vector 3 to get the directions for all 3 in one vector?
or just multiply the WHOLE quatenion with a Vector3.forward
the whole thing
never split apart a quaternion into it's individual xyzw, it's going to be nonsense
I think my VRCPlayerAPI isnt working
Cause I have a Start event that checks a bool thats updated based on the IsinVR node
then it gives a message in the Debug log
i got no message
works in unity but not in game
Udon breaks when you have multiple execution lines flowing into one node like this
I'll remove that but I added that after i noticed my stuff not showing up in the ingame debug
This debug is supposed to give me my head position, rotation on keypress of Keypad 0
along with another message sayingit was pressed
this does not show up ingame
nor does my debug ray draw
bump
Setprogramvariable
do i put that in the script thats calling the behavior or the behavior itself?
Try recompiling your scripts. Are you sure you're dragging in an object with an udonbehaviour though?
Check your log to see if the udonbehaviour is halting?
It's not halting
I do not know why but this does not work I wanted the player to teleport when I click door.
Ah I see. Thanks!
getting this error when trying to get an object from an array, the array has 9 objects and im trying to call object 0
You're calling an index that is not defined, is the element defined in the array?
That or you're calling an index outside of 0-8
None of my dbug logs are showing up in the ingame logs
so i cant tell whats broken
it works in unity
not ingame
i set every 'get' node int in the graph to 0 and it still got that error, so it cant be that
it might be some issue with the system i have to convert a pool into the array
Looks like it's trying to get the game object of a collider, and is failing to do so. Is collidervariable setup with a value or instantiated?
I ended up removing that whole gameobject stuff
Now it takes the collider and gets the coponent i need
So when the ray fails to get a collider its empty
And when it find one without the coponent it doesnt do anything
You need to check if the collider is valid before trying to do something with it
Hello, if I'm using UdonSharp instead of the graph, are my questions suited for this channel or should I go to #world-development ?
You're good, all Udon is allowed here.
Thank you. I have sliders that I can adjust in-world to change parameters of game object components... When I tested it a few weeks ago, a guest was also able to use the sliders, but they only affected his perspective locally. Is there a way to have sliders that only I can control? (I guess "I" would be the Game Master, ie. the person who first made the instance, or the next in-line after that one leaves - if my understanding is correct)
ie. I'd want it so guests can't even change the parameters locally.
so you want a change you make to apply to everyone, but you don't want them to be able to make any changes?
@indigo finch Yes, is that possible?
certainly. you would need to make a synced float variable, then whenever your slider value changes, make it update this sync variable. A synced variable can only be changed by the owner of the object, which will default to the instance owner. Then you just need to make it so that when that float variable changes, it updates the value for the slider, which can be easily done with a property.
Also, add a little bit of logic so that when the slider changes, but the person isn't the owner, it corrects itself to the synced float value
@indigo finch Thank you! Is this the correct syntax for a "synced float variable"?
[UdonSynced] public float poo;
yup, though it doesn't need to be public ^^
Believe it's 'Networking.LocalPlayer.IsOwner(gameObject)'
@indigo finch I'll try that out, thank you. So I'd put the slider's gameObject as the argument.
sorry, I'm more use to udon graph, so all my coding repertoire is kinda lacking...
Might be kinda basic, but I'm a little lost as to what you mean
Oh, you sounded like you knew what you were doing til now! ๐
I know what I'm doing, just not how it's normally said ๐
@indigo finch for the (gameObject), you'd put the slider in those parantheses, is what I meant.
it would be whatever object the script is on, thus 'gameObject'. We want to know the owner of the script that has the synced float on it
ohhh, I see. Got it!
btw, slight correction to what I said before, but you only need Networking.IsOwner(gameObject) instead of Networking.LocalPlayer.IsOwner(gameObject)
@indigo finch Do you mean something like this? I tried to follow your instructions, but unsure of how to use a property here:
oh, I can move that first line outside of the foreach loop
To fact check what I was saying, I made this example:
also made it for graph XD
ah, so FieldChangeCallback is an Udon-specific property?
and wow, you're going all out. xD
oh, my bad. the property's at the bottom
I'll probably make a video covering how to sync a slider value, as it's not an uncommon thing for people to ask, so I figured I might as well make an example for me to come back to later
actually, maybe there already is one? You answered me before I watched it ^^; https://www.youtube.com/watch?v=ecu9oaUxClI&ab_channel=VRChat
Learn how to use Udon to make a slider that shows its value and syncs to everyone else in the world.
0:00 Building a Slider
2:54 Adding a Text Field to the Slider
5:04 Showing Slider Value in Text Field Using Udon
9:52 Syncing the Slider Value over the Network
13:42 Restricting Variable Updates to Owner
14:46 Switching to Manual Sync
16:26 Rest...
though he shows how to do it with the graph, not c#/u#
Neat, good to hear there is something out there (not always the case). This video is with old udon though, before they added the 'onVariableChanged' events. They also didn't cover how to take ownership of the slider so that anyone can change it's values. Still, it does cover a bunch of good stuff ^^
@indigo finch What happens if I leave out the line "mySlider.value = sliderValue"?
Wouldn't it be fine, since the SliderValue property is set from mySlider.value to begin with, and only when the owner is accessing it?
and what does the FieldChangeCallback do here? It sounds like it'd be an auto-generated property.
perhaps you could add a 'isOwner' check, but that line of code will update the slider value for everyone else, when the synced float changes
ahh, I see!
I'll be honest, I don't know its origin or anything, other than that is the thing that you do to get the equivalent of 'onVariableChanged' event nodes found in graph
if you look it up, would love to hear what you find ^^
there's no obvious definition page when you Google "udon FieldChangeCallback"
I found this for it while ago. https://github.com/MerlinVR/UdonSharp/wiki/UdonSharp#fieldchangecallback
When do you think we will see support for lambda expressions and predicates? I use those a ton at my work and I feel like doing my enumerations to search my arrays is pretty punishing to the game.
Disappointingly, Array.Exists, .Contains is not exposed.
@dawn forge Ah, thank you! So it looks like it shouldn't be a necessary attribute if you never try to set the field directly, right?
@indigo finch And your code worked, thank you!
That's correct, I barely use it unless I am syncing manual fields. synced fields doesn't need this attribute either, but this paradigm is fantastic to have your code short and clear instead of checking if the value has changed every OnDeserialization.