S
S
Stepgor2020-02-15 01:01:59
Unity
Stepgor, 2020-02-15 01:01:59

Why does the position not change?

The character falls from y = 50, there is a plane trigger on y = 0.
The script is attached to the character, the log outputs, but the position does not change (the character is assigned to obj).
What could be wrong?

void OnTriggerEnter(Collider other)
    {
        Debug.Log("TRigger");
        obj.transform.position = new Vector3(0f, 300f, 0f);
    }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
TailsMiles54, 2020-02-20
@Stepgor

Something like that. I would describe more precisely what is happening on your stage in general.
obj.transform.position = obj.transform.position * new Vector3(0f, 300f, 0f);

E
Evgeny Museev, 2020-02-16
@Zimo

Try this
void OnTriggerEnter(Collider other)
{
Debug.Log("TRigger");
transform.Translate(Vector3(0f, 300f, 0f));
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question