This is my teleport udon code, It is the basic teleport code
There’s a few ways you could do this + the best way is probably to build it around/alongside your core game systems – but I know that’s probably not too helpful.
Here’s a starting point:
It’ll countdown from whatever time you set in the ‘spawnCountdown’ public variable field on interact + print that time to a TextMeshPro element. When the time reaches 0, it will teleport all players to random spawn point transforms you can set, reset the timer and then disable itself (so you can re-enable later in your game logic).
You’ll need to setup a UI canvas with a TMP object that’s blank and populate the spawnPoints array in the inspector with however many spawn points you have.
You can copy and paste what’s below into your graph too…but I’d still suggest rebuilding it yourself from the screenshot. It’s commented! It’s good to learn and you might have your own specific use cases
hope that helps / much love
Thank you so much for the reply, this is all new to me so I’m a little bit confused, but I know i’ll figure it out, if not I’ll ask for help! thank you!
I created the canvas, but when I create the TMP do I do the Button TMP or the Text TMP. Also what do you mean by and populate the spawnPoints array in the inspector.
Also what is the eventSystem? is it a gameobject? Figured out it was a gameobject. Is it just a random game object meant to start the event, or do I have to put it somewhere for someone to interact with it.
Simpler question, where does each set of code go to. I figured out that the Custom event goes to the respawn interact Gameobject, and the countdown goes to the countdown gameobject, but where does start go to and where does interact go to?
…Button TMP or the Text TMP…
Text TMP - as you want it to display text (the countdown)
…populate the spawnPoints array…
In the Inspector window (on the most right-hand side going off your screenshot!) Under the Udon Behaviour component, you’ll see a “spawnPoints” public variable with a dropdown.
Click the dropdown + that’s where you’d add however many spawn point transform/game objects you have.
what is the eventSystem?..
It gets created whenever you add a UI/canvas to your scene - it’s basically so you can interact with UIs. You can ignore it for this!
…where does each set of code go to…
The program/graph should be on your ‘Interact’ game object (i.e the object you want to interact with to make things happen). You ‘reference’ other objects like the countdown text by filling the public variable slots that will be under the Udon Behaviour (basically described above with the spawn points).
To understand this graph better in the interim, the gist is that Start happens automatically once at start (right as you load into the world). Update is called every frame while the behavior is enabled. Interact happens when you interact with the game object. The custom network event [“TeleportPlayer”] is called or “triggered” if conditions are met (in this case, if the countdown is finished) and that happen within Update.
There’s some really great starter graph tutorials that can get you started with understanding event nodes, variables, etc. and how they all connect better than I could here in text.
For my dropdown menu it says size: 1
0: None (Transform)
Nvm: the variables weren’t public
I actually understood the graph, I was just a bit confused, because I had the issue where I cant have more than one interact events which made me think I can only have one event per graph.
Just add the number of spawn points you have to the size and fill the array with the transforms/objects. (Make sure the variables are public too, it should automatically do that with the copy + paste but I’m not fully sure)
…only have one event per graph.
Ah! You can have different events going off in a graph, but yeah - you’re right. Just one interact event (although of course, you can make that interact event do different things with branches if that’s something you need down the line)
So I actually did everything in the graph, and I tested it out and it took 3 seconds, but there wasn’t a countdown and I didn’t teleport the interact button dissapeared. Also the “size” column disapeared after doing the whole graph, idk where it went. Last thing, wdym by the array, cuz I have all my spawn points grouped up in one game object. where you have the down arrow.
Hmm, that’s a bit difficult to troubleshoot here.
Here’s a .unitypackage I exported out that should have things pre-configured so you can look through / reverse engineer to see how it’s setup.
We’re using arrays so we can take a list of spawn points + pick one randomly to teleport the player to. It’s okay that you have them grouped/parented, but you’d need to fill the “spawnPoints” array with the individual spawn point game objects still with how this graph is setup!
I will do that, but would it somewhat help to look at a screenshot of what my unity looks like?
I might be able to pick out something that’s causing issues. If I can’t catch what’s going on, possibly someone else here can!
Uploading: Screenshot 2022-01-09 133122.jpg…
found an error. interact event isn’t connected: this didn’t do anything to my issue
Not sure why the Interact noodle would disconnect
I don’t see anything off with the graph besides the Interact not being connected.
What does the ‘spawnPoints’ array dropdown look like in the Inspector window when you click it open?
I’d also check to make sure your UI canvas is setup correctly for what you’re trying to do. Likely you’d want it to be in World Space, make sure it’s scaled properly, etc. The .unitypackage should have it setup for you to reference or use/modify
ah yeah, it needs to be in world space if you want to be able to move it above the button, etc.
I meant the ‘spawnPoints’ dropdown on the Udon Behaviour component in the inspector window on the right side! It should look something like this when you click it open:
In your case (if you haven’t already done this), you’ll want to set the size to 13 + drag-and-drop the spawn point game objects over to the slots from your scene hierarchy on the left!
I’M DUMB. the arrow wasn’t down the whole time… I figured it out, I added 14 so now they are there
IT WORKS! main issue is that its counting down with decimals.
Fixed the decimals too, apparently I needed the 0 in the code
you’re not dumb! learning experience~
but yeah, you got it! The 0 specifies the format when you convert the float to a string
Hey, I’m just gonna keep using this thread, but any chances I can keep asking you questions about udon as I build my game?
I have some more questions
-How can I create it where the owner can only start the game and where the first person is the owner.
-How can I make it where the countdown happens for everyone in the game? because the countdown only happens to the person who pressed the button
-Is there a way to get a keybaord in Udon, so that when someone types on the keyboard it appears in a text box and when you are done typing, you press done, but it doesn’t send to a different player until everyone pressed done? I’ve been trying to find Udon keyboards, nothing, so I’ll probably just forget the keyboard right now.
-How do I add pens and an area where you can only draw. When a timer runs out the canvas (drawing area) teleports to a new player or the new player teleports to the canvas.