GetComponent<RigidBody>().angularVelocity = Random.insideUntSphere * tumble
rigidbody component中的angular drag是角速度的空气阻力
Instantiate(gameObject,transform.position,transform.rotation)在游戏里生成一个gameObject,后两个参数是将要赋值给gameObject的transform和rotation gameObject可以有自己的script,比如Start()函数里设置velocity从而给它一个初始速度。
Collider勾选isTrigger代表碰撞作为一个trigger。 相关函数示例:
void OnTriggerEnter(Collider other)
{
Destory(other.gameObject);
}
void OnTirggerExit(Collider other)
{
Destory(other.gameObject);
}
public float fireRate;
private float nextTime;
private void Update()
{
if(Input.GetButton("Fire1")&&Time.time>nextTime)
{
nextFire = Time.time+fireRate;
Instantiate(Shot,ShotSpawn.position,ShotSpawn.rotation);
}
}