I’m having two rigid bodies in my game. I’m using rigidbody2D.addForce to move these rigid bodies. When they collide with a non-rigid body collider/gameobject they don’t move after collision. But, when they collide with each other(colliding with an rigid body) these objects move after collision, depending upon how much force is applied. I cannot destroy rigidbodies after collision because I’m using those for their movements.
Below is how I’m moving my objects :-
if (Input.GetKeyDown (KeyCode.RightArrow))
{
//transform.Translate(0.5f, 0, 0);
rigidbody2D.AddForce(Vector2.right * swipeSpeed);
}
if (Input.GetKeyDown (KeyCode.LeftArrow)) {
//transform.Translate(-0.2f, 0, 0);
rigidbody2D.AddForce(-Vector2.right * swipeSpeed);
}
if (Input.GetKeyDown (KeyCode.UpArrow)) {
//transform.Translate(0, 0.2f, 0);
rigidbody2D.AddForce(Vector2.up * swipeSpeed);
}
if (Input.GetKeyDown (KeyCode.DownArrow)) {
//transform.Translate(0, -0.2f, 0);
rigidbody2D.AddForce(-Vector2.up * swipeSpeed);
}