OnTriggerEnter can't change detected gameObjects transform.position

void OnTriggerEnter(Collider other)
{
if(other.gameObject.CompareTag(“Player”) && canrespawn)
{
other.gameObject.transform.position = new Vector3(0f, 0f, 0f);
}
}

Tried many variations, but can’t workaround the fact that transform is only Get (read-only). I could simply fix this by placing the code on the object i want to move, but i don’t want a lazy workaround just so that it bites me in the back later.

Cheers.

I would make a variable to represent that object and then use that instead of using tags like this:

public GameObject Player; 

void OnTriggerEnter(Collider other)
     {
         if(GameObject && canrespawn)
 {
5.                     other.gameObject.transform.position = new Vector3(0f, 0f, 0f);
 }
         }

I don’t know if this is exactly what you want or what you are asking in that if statement, but I think you can make this into what you are doing

Hope this helps :slight_smile: