Монстр
MonsterShoot2D | MonsterShootToPlayer2D |
public GameObject bullet; public float horizontal = 500.0f; public float vertical = 0.0f; public float bulletTime = 5.0f; public float firePause = 3.0f; void Start () { InvokeRepeating("F1", 1.0f, firePause); } void F1 () { GameObject go = Instantiate(bullet, transform.position, Quaternion.Euler(0, 0, 0)); go.GetComponent<Rigidbody2D>().AddForce(new Vector2(horizontal, vertical)); Destroy(go, bulletTime); }
Гравець
Shoot2D |
ShootToMouseDir2D |
- Пустий об'єкт RotatePoint в середині гравця (0, 0, 0)
- Приціл BulPos в середині RotatePoint (2, 0, 0)
- У RotatePoint додаємо ShootToMouseDir2D