完整代码
public float climbspeed = 2f;
private bool inLadder;
public Collider2D platf;
private void OnTriggerStay2D(Collider2D collision)
{
if (collision.tag == "Player")
{
if (Input.GetKey(KeyCode.UpArrow))
{
collision.SendMessage("setLadder", true);
collision.SendMessage("setInLadder", false);
inLadder = true;
collision.GetComponent<Rigidbody2D>().gravityScale = 0;
Physics2D.IgnoreCollision(collision.GetComponents<Collider2D>()[0], platf);
Physics2D.IgnoreCollision(collision.GetComponents<Collider2D>()[1], platf);