- Home /
Question by
Patton7 · Apr 27, 2019 at 11:47 PM ·
rotationrigidbody2dvelocityphysics2dprojectile
2D rigidbody velocity relative to rotation?
Hello everyone. Pretty much I am instantiating a bullet prefab with this function:
void Fire()
{
bulletPos = transform.position;
bulletPos += new Vector2(+1f, -0.0f);
Instantiate(bullet, bulletPos, Quaternion.identity);
}
And I am adding force to the prefab with this code on a different script:
rb2d.velocity = new Vector2(velX, velY);
Destroy(gameObject, 3f);
However, my player is also rotatable, and when I rotate it, the bullet prefab does not also instantiate at that rotation, but rather still instantiates at the one same rotation, even if I have rotated my player. Does anyone know what I am doing wrong and how to fix this error?
Thanks.
Comment