Question by
Ryan_Murf · Oct 31, 2020 at 11:06 PM ·
scripting problemprefabrigidbody2daddforcerigidbody.addforce
Bullet not moving rigidbody2d,AddForce not working for bullet
Hello, I am currently trying to create a enemy in my space shooter that spins and fires random bullets. My issues is when it fires the bullets the bullets are stuck where they instantiated. I am trying to use addforce but I must be doing something wrong.
GameObject laser_1 = Instantiate(E_Bullet, shootDirection1.position, shootDirection1.rotation);
Rigidbody2D RB = E_Bullet.GetComponent<Rigidbody2D>();
RB.AddForce(transform.forward * E_Bullet_Speed);
Also here are the setting of my bullet which is fired from a empty called shoot direction.
rigbody.png
(27.4 kB)
Comment
Answer by sevalk · Nov 05, 2020 at 06:05 PM
Transform laser_1;
Void Update()
{
laser_1 = Instantiate(E_Bullet, shootDirection1.position, shootDirection1.rotation);
laser_1.GetComponent<Rigidbody2D>.AddForce(laser_1.forward * E_Bullet_Speed);
}
Can you try this.