hi so this is my first time asking for help so if I forgot to mention something sorry
so I’m working on a 2D project (still in early testing) and i was trying to make a movement script that controls 2 rigidbodys. the script was originally just for one RB but i added a second RB to it.
when I changed the movement script to control both of the RBs the game would crash each time i tried to test it
here is the code in question. the parts in bold are what was added when i made it start controlling two RBs
public float moveSpeed = 5f;
public Rigidbody2D rb;
**public Rigidbody2D swordRB;**
Vector2 movement;
public playInformation stats;
void Update() {
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
}
void FixedUpdate() {
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
**swordRB.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);**
}
other than this I cannot think of anything else that may give more insight, but if you need any other information let me know.