How To Animate a PressurePlate?

Hey guys I figured out how to make a pressure plate in 2D but now I cant figure out how to animate it to where when my 2D Stickman Ragdoll steps on the pressure plate it sinks down and when your not on it, it goes back up. Here is the code I have for the pressure plate that opens the door.

Can anyone Help me?

// paste your code here
```using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Pressureplate : MonoBehaviour
{
    public Vector3 originalPos;
    bool moveBack = false;
    public Animator anim;

    public GameObject door;

    private void Start()
    {
        originalPos = transform.position;
    }

    private void OnCollisionEnter2D(Collision2D other)
    {
        Debug.Log("OnCollisionEnter2D triggered with " + other.gameObject.name);

        if (other.gameObject.CompareTag("Player"))
        {
            door.SetActive(false);
           
        }
        else
        {
            door.SetActive(true);
        }
    }

    private void OnCollisionExit2D(Collision2D other)
    {
        if (other.gameObject.CompareTag("Player"))
        {
            door.SetActive(true);
           
        }
    }
}

![Screenshot 2024-03-24 173149|439x500, 50%](upload://5f6y2THyArJxmQbwavqXfDXDYB3.png)

Check out this animation tutorial:

It will solve your problem.

@INEVERMINE A screenshot please!!

Makes it easier to solve the problem

Don’t still fully understand the question, but you said “animating down” so I’m guessing you just want it to move down slowly. No need for an animation here.

Just add

public float Speed;

and

Rigidbody2D.Move(new Vector2(0,-1) * Speed);

to your if statement in the OnColliderEnter method

To move it down. Set Speed in the Inspector.