2D物体速度

定义物体刚体

pubilc Rigidbody2D rig;

定义物体速度

public float ballSpeed = 15f;

在Start函数中

  获取刚体

  rig = GetComponrnt<Rigidbody2D>();

在Updata函数中

  赋予物体速度

  rig .velocity = Vector2.up * ballSpeed;

销毁物体

  在Start函数中

  三秒后销毁

  Destory(this.gameObject,3);