OnTriggerEnter too slow?

This is my code, and it works… BUT there is (like always) a flaw.

private bool w = false;

void Update()
{
    if (Input.GetKeyDown("w"))
    {
        w = true;
    }

void OnTriggerEnter(Collider otherObject)
{
    if (otherObject.tag == "walls-blocks")
    {
        Debug.Log("(PlayerHitWall) Player hit: " + otherObject.name);

        if (w == true)
        {
            gameObject.transform.position = lastPosition;
        }
    }
}

As soon as my player collides with a WALL, it gets placed back to it’s last position. But, if I rapidly pressed W (moves against the wall) it moves THROUGH the wall after 5 times tapping W. Is this because the update method of OnTriggerEnter is slow? Any idea on how to fix this?

This could be happening because OnTriggerEnter depends on physics, and Unity physics are processed on the fixed update function. So, if you’re updating the position in a regular Update function, it’s probable that it will run faster than the FixedUpdate function, since it has a variable framerate. Why not use the default collision reaction setup?