I have a script attached to a trigger collision at a shop door, and I was using it to change scenes, but I’m now wanting to just use transform.position to teleport the player in the same scene to the shop. But what I’m wondering is how to use the transform command on the player while the script is a component of the trigger collision. Any help is appreciated!
(I use C# btw)
All you need is a reference to the object you want, and you can get that in a number of different ways depending on the situation. In your case, since you’re using it in a trigger collision, you can use the “other” collider that gets passed into the function:
void OnTriggerEnter(Collider other) {
other.transform.position = somePosition;
}
Awesome that’s exactly what I’m looking for, thank you!