I am trying to figure out how I can make it where when someone (owner) presses the start button a countdown appears for 3 seconds and everyone gets teleported to a seperate spawn location. It is for a game

This is my teleport udon code, It is the basic teleport code

hey there! :wave:t2:

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

application/vnd.unity.graphview.elements AO1c23LUSBL9FULPLkfdL0TwAJ4ZwjHLLIONX3YIR12yoJe2RKjVgJfhy/ZhP2l/YVNud6vdEmMtuE17xsCD1FaXsvJy8mRWmv/++z+fivd+Oofi4T8+FXk+nf7iz/CmOPH1xIcpnB6dzxo4e1JVU/BlsVfMJwl/TAPIrI0iIJUmUnFPrE6aWMtsEDbKYB0+/K6aTZpJVRYPPxUfi4eECWblvtorzvFGMar21ee9oqwSvDz8YYYyFPil7t+rvSJPqw+XP3u1ePKkFXd2Ie+8nDTnfw//hNicLDbxqZiUs8aXEQ5/KB5SXHzW1JPy9eWPi+Lz3td8baGE/aOLD/cenM1iVU8nYe/BCdQz3N8juU/bv3sPDubTZl7DoxLmTe2new+ez8N0En+G8+PqLZSPgjFeRaWZExKodb/Hal42qfpQHs4ex2byHr5NxEtD3ayMP/np7E8q1zZMWlYlSvWqlevLEXWEr53CKqA4/kmZW5K0jEQmcMQLqkjQNIPKzplwH1CjtN9MzuAFnPlJiUv/OZ12V+X6DsF0/Ox5XR3Dx+YZzN7g5cunLw9XQSWyyxKiJtlxR2QUmjiInGTFGGhuomFyKKgUlWwVVEbJ+6BaZalW1TvovMf1/D6mtpqgkuGCpRCJNgYZn5GOWB8zyTQG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JdOhL9vyjyp9+Kj7/hu/ELvxXnq6t/La4+34Dgne/crux49WG1i1G4r0ACOpImAiQSNms4aYdKScA4Uz4ro+XAyQtZP3phtH+YdbeQf9SA+hZ49tV5eUSn1kTLU5eyEfx0cLq+O3d3SjrpgNiIdpO+rZBEdMQHhKO2iwIw9Csrli85DnH9MnqMR1wgC/4I3y85SRKwOskuEi99Il6DTJZizqJ+l5Dl0oEuFHubp+MvfJmqM7QuXryGq/a9Yuu1m5WJxyh5KD4pX5bBYrCTbYRmGnMUMSJbIhkF9AXMYcZCxkIzGkxtWzHeVq1wp/yiF/1t5+xvUL5u3gz7whibDfkCc3pVz31tuN9G0Tekm0u1LPc0RNq6wcERnGhAP7KjzwNwOAZjv79+6qrxPf10LGRttvJ6NjikIrdiraw/1LxDKup4/2WLFZ9eRlYV/XRRCly0sgfqg655MIKGD3rSakyp/V8LvmlMaVEgXvSMfWy6Oh2icaJtsKlWMhuAhACoeoHFY25LdSYGJDNiNWYx0NPZKBAFpcFSn0nMoW07Rk984pKAE06rSA3j7usGWket3JdeCNdJP5jOEBmTQAQjNHh0QUCDhYBubiD7xKRuX7ytxsz9oettNDaHT13H2H0oUHU3xj9Qhd+xc9fhw+oFgBw1vu7QI2YjMwRFRJQZ/UkFYh1CSJLe2AxSxkH4Z9ys9GV4bw5nAz5iQpoqGPISqtsuFqckeMeIQk7qnPcg4/W/SjgIH6NWHiLDUnbi9/MXfsVxLgJYR3IG1541WRKUcUSnyFjKPGR/F/HjfkDoi/MHIww+GAlqleKVG5hIu1PuseXzxVef/wc=

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.

Oh yeah!

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

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.

Here’s a vid of how it should work

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 :thinking:
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

Changed it to world space in the photo

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!

Screenshot 2022-01-09 152018

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

:laughing: you’re not dumb! learning experience~

but yeah, you got it! The 0 specifies the format when you convert the float to a string :+1:t2:

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.