【Uinty3D】2D飞机的基础——子弹速度及销毁

2D物体速度

定义物体刚体

pubilc Rigidbody2D rig;

定义物体速度

public float ballSpeed = 15f;

在Start函数中

  获取刚体

  rig = GetComponrnt<Rigidbody2D>();

在Updata函数中

  赋予物体速度

  rig .velocity = Vector2.up * ballSpeed;

销毁物体

  在Start函数中

  三秒后销毁

  Destory(this.gameObject,3);

猜你喜欢

转载自www.cnblogs.com/Whiteying/p/10102392.html