bullets intantiate with no problem but when i try to apply forces they don’t move. I have the prefab connected and rigidbody2d on the bullet prefab.
Thank you for your time/help.
if(facingright == true){
var bulletInstance : GameObject = Instantiate(bullets, transform.position, transform.rotation);
var bulletInstanceRigidbody: Rigidbody2D = bulletInstance.GetComponent(Rigidbody2D);
bulletInstanceRigidbody.velocity = new Vector2(10, 0);
}
I’m taking an educated guess here, but I think that you are retrieving the velocity of the bullet, rather than pushing it. Try using
rigidbody.AddRelativeVelocity(Vector3). Check the spelling on that
This should add velocity and make your bullet move.
EX
if(facingright == true){
var bulletInstance : GameObject = Instantiate(bullets, transform.position, transform.rotation);
var bulletInstanceRigidbody: Rigidbody2D = bulletInstance.GetComponent(Rigidbody2D);
bulletInstanceRigidbody.AddRelativeVelocity(10, 0, 0);
}
This works in 3d, I have never tried it in 2D.
Good luck