Is it possible to link an animation to a place?[JS]

So I made an animation that, if I can, I press a button by a machine and stuff happens but I need to be in a certain area of the machine. Is it possible? If so how? I have the button code down just not the area part. Thank you for any help.

Is that 2D or 3D?

But anyways just add “invisible” trigger collider there on the area,
then if you are inside it, you can do the action.

You can check when player enters the trigger,

and when exits,

1 Like

Its 3d

Im haveing a few problems
Assets/SodaDrop1.js(2,9): BCE0043: Unexpected token: function.
Assets/SodaDrop1.js(2,34): BCE0043: Unexpected token: other.
Assets/SodaDrop1.js(2,51): UCE0001: ‘;’ expected. Insert a semicolon at the end.

function Update()
function OnTriggerEnter (other : Collider) {
{
if(Input.GetKeyDown(“q”))
{
// Plays the popdrop animation - stops all other animations
animation.Play(“popdrop”, PlayMode.StopAll);
}
}
}