First Item of an array doesn't create Joint (Solved)

Hello, anchor guy again with another anchor-related problem. While I’ve found a solution to the issue we had while creating a series of joints with an array (here’s the link to the other Topic: Create Joints with array/Table (SOLVED) - #3 by DandyDan ) I found a new problem: it read a nil value when it tries to create a joint between the main anchor object and the first link of the chain

As you can see in the previous image the links have their joints created without any issue. But it should appear “joining chain_piece1 with main_anchor” and it obviously doesn’t. All game objects have two collision objects with a circle shape so they can connect, while the anchor has three, both of the circular collisions are present and with the same name as the other ones.

image

I’ve tried to exclude the main_anchor object from the list and tried to join it with the first chain_piece with another line of code but that didn’t seem to work either. Any tips on how I could solve this?

1 Like

Well, what are you passing to the function?
Have you printed out the variables?

It seems from your error that you are using a variable that is either previously unassigned, or has become nil. And you cannot create a string like this: nil .. "foo"

1 Like

I’ve been trying to look for something that could’ve been a Syntax error on my end but when I re-built the project it worked fine.

With a little of trial and error we realized that the code as it is written right now creates the joints in an incorrect other. Instead of getting the “joint_top” from the first item and creating a joint with the “joint_bottom” of the next one is trying to creat a joint between the “joint_bottom” of the first and the “joint_top” of the next.

Switching around the values of the positions and the collisions has worked and now functions as intended. Sorry for the Topic and thanks for the help!

2 Likes