Hi, I am making a gadget game and could use some help, as many others my coding experience is limited. I have tried finding the answer for this but after seaching for hours i know dare ask this as a question.
I am building a two static teleporter(two telerporter stations that can be used both ways)
buildig a one way teleporter was easy enough(see code below) what i did was create a colider that when anything colides it sends the object to a destination.
public class ColliderTwoWayStaticTP : MonoBehaviour
{
public Transform destination;
float lastTP;
void OnTriggerEnter(Collider other)
{
if (Time.time > lastTP + 3)
{
//if (other.CompareTag("Player"))
//{
other.transform.position = destination.position;
lastTP = Time.time;
//}
}
}
}
and i attach this to the colider as seen as the top square on the picture PICTURE
this work as expected, the teleporter transports the player, or anything else for that matter to the chosen destination.
now the next step would be to access what happens when another gameObject (in this case the number2 teleporter station) collides with something(anything)
so i would add something like this (**this is not real code**)
public GameObject exit
onCollisionWith(exit,Collider other)
{
if(Time.time > lastTP + 3)
{
teleport other to this.position
}
}
the onCollisionWith is off course not a real function, but this should give the idea of what i am looking for, some way to access the collision happening between a public variable(gameobject or whatever)
I hope this is clear enough
I have a web build of the oneway teleporter, but i can only post one link so PM me if you want it
PS: any help would be appreciated, whether it be in Java or C#