Hello,
I’m trying to do a teleporter with Udon. I want to pass a vector variable between two script, like in the following screenshots.
What I want to do is teleporting the player from a position respect to the teleporter, to a position that have the same relative postion to the receiver. So I need to pass the difference between the position of the player and the position of the teleporter object.
Do I use Get Program Variable like this, or am I doing it wrong? What do I use as instance?
thanks for helping, I’m a newbie
Sender:
Receiver:
I don’t think this’ll be possible with Udon Graph, but it’s fairly simple with Udon #
Essentially what you need to do is get a reference to the other program, and then you can just get the variables from that reference.
Sender:
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
public class Sender : UdonSharpBehaviour
{
public Transform playerPos;
public Transform targetPos;
void Start()
{
}
void OnTriggerEnter(Collider player)
{
playerPos = player.transform;
}
}
Reciever:
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
public class Reciever : UdonSharpBehaviour
{
public Sender senderObject;
void Start()
{
}
void someTrigger()
{
Networking.LocalPlayer.TeleportTo((senderObject.playerPos.position+senderObject.targetPos.position), (senderObject.targetPos.rotation));
}
}
Note it’s just an example some one smarter than me might know how to do it in udon graph, but this would be roughly how you can pass things in udon#
2 Likes
Thanks, I still didn’t try Udon#… maybe it’s time to start…
Anyway, It seems impossible to me that a simple concept like that cannot be done in Graph…
Is it possible, maybe, getting the position of the object “teleporter”, directly from the object “destination”? So i can make math from there, without passing variables.
Well what do you need help with and what have you tried so far?