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.
Answer by SmokiestSpace6 · Mar 12, 2016 at 09:42 PM
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 :)
other.gameObject.transform.position = new Vector3(0f, 0f, 0f);
This is the part i am having trouble with. Your suggestion is a quality of life improvement, thanks :). This part doesn't work because transform is only Get while i need to get and set it.