Refering to another object and changing its properties

I’m relatively new to Unity and am having a problem with something that I’m sure is very simple.

I have an area in my game set up as an invisible trigger that will go off when the player enters it, what I want this trigger to do is remove all the players momentum so they stop in the area.

I know I’ll need to change the rigidbody velocity and angular velocity to 0 but for the life of me I can’t work out how exactly to do this, I don’t know how to refer to the player object on this trigger script and then set the velocity to 0.

I imagine it’s something along the lines of Player.rigidbody.velocity = 0 but I don’t know the exact code to use.

Any help would be appreciated

The OnTriggerEnter function (or OnTriggerStay) gives you a collider reference of the object that enters / is inside the trigger. Just use this reference and set the velocity to Vector3.zero (since it’s a vector).

//C#
void OnTriggerEnter(Collider aOther)
{
    if (aOther.rigidbody != null)     // Does the object have a rigidbody?
    {
        aOther.rigidbody.velocity = Vector3.zero;
    }
}

Note: OnTriggerEnter() is called only once when a player / object enters the trigger. If you want to block the player totally you might want to use OnTriggerStay()