public BulletController(BulletModel bulletModel, BulletView bulletPrefab, Vector3 position, Quaternion rotation)
        {
            BulletModel = bulletModel;
            BulletView  = GameObject.Instantiate <BulletView>(bulletPrefab, position, rotation);

            //BulletView = GameObject.Instantiate<BulletView>(bulletPrefab);
            BulletView.SetBulletController(this);
            BulletModel.SetBulletController(this);
            rigidBody = BulletView.GetComponent <Rigidbody>();
        }
예제 #2
0
    public void Throw(Transform transform, Vector3 velocity)
    {
        Rigidbody2D bulletRigidbody = _bullet.GetComponent <Rigidbody2D>();

        _bullet.SetVisible(false);
        _bullet.transform.position      = transform.position;
        _bullet.transform.rotation      = transform.rotation;
        bulletRigidbody.velocity        = Vector2.zero;
        bulletRigidbody.angularVelocity = 0;

        _bullet.SetVisible(true);
        bulletRigidbody.AddForce(velocity, ForceMode2D.Impulse);
    }