Unity 2D Постріл

Монстер

public GameObject bullet;
public float horizontal = 500.0f;
public float vertical = 0.0f;
public float life = 5.0f;
public float pause = 3.0f;

void Start () {
   InvokeRepeating("F1", 1.0f, pause);
}

void F1 () {
   GameObject go = Instantiate(bullet, transform.position, 
                               Quaternion.Euler(0, 0, 0)) as GameObject;
   go.GetComponent<Rigidbody2D>().AddForce(new Vector2(horizontal, vertical));
   Destroy(go, life);
}



[ Більше ]