# Chapter 10: Challenge - seesaw joint by code

**URL:** <https://forums.kodeco.com/t/chapter-10-challenge-seesaw-joint-by-code/22173>\
**Category:** 2D iOS & tvOS Games by Tutorials\
**Created:** [November 3, 2016, 4:34pm UTC](https://forums.kodeco.com/t/chapter-10-challenge-seesaw-joint-by-code/22173 "2016-11-03T16:34:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sonoblaise](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@sonoblaise](https://forums.kodeco.com/u/sonoblaise)\
**Post date:** [November 3, 2016, 4:34pm UTC](https://forums.kodeco.com/t/chapter-10-challenge-seesaw-joint-by-code/22173/1 "2016-11-03T16:34:45Z")

</div>

I’m trying to figure out what I’m doing wrong. I can pin the seesaw in the scene editor and it works fine. But by code, it doesn’t work. I add the joint in the didMove(to) method and when I run it, it looks like it’s actually pinned in the center, but its movements are erratic and after a while it simply crashes. Since it’s a temporary thing in the challenge, i can’t seem to find the solution for that step anywhere.

I tried every way of unwrapping optionals I know in hope it would change something, I tried to set the rotationSpeed and frictionTorque before adding the joint to the physicsWorld without any change in behaviour.

what happens is that the level starts and I already lost the game because the seesaw seem to be wiggling at a 45 deg angle super quickly and it seem to have thrown the cat away as well as the top block.

here is my code that I put at the end of didMove():

```
if let seesawBase = childNode(withName: "seesawBase") {
            if let seesaw = childNode(withName: "seesaw") {
                let seesawJoint = SKPhysicsJointPin.joint(withBodyA: seesawBase.physicsBody!, bodyB: seesaw.physicsBody!, anchor: seesawBase.position)
                physicsWorld.add(seesawJoint)
            }
        }

```

Thanks in advance for your help.

---

<div class="post-metadata">

**Author:** ![jean\_pierre](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jean_pierre/32/46204_2.png) [@jean\_pierre](https://forums.kodeco.com/u/jean_pierre)\
**Post date:** [November 14, 2016, 12:06am UTC](https://forums.kodeco.com/t/chapter-10-challenge-seesaw-joint-by-code/22173/2 "2016-11-14T00:06:50Z")

</div>

I ran into the same thing and after a bit of searching on the forum, found the same question for an older version of the book:

> [@Pinning the board in chapter 11](https://forums.kodeco.com/t/pinning-the-board-in-chapter-11/12757/1):
>
> Hi! I’m looking for the code for pinning the board in challenge1, chapter 11 of 2D iOS & tvOS Games by Tutorials. It doesn’t seem to be presented in the book. The question has been asked before, according to a Google search. However, when clicking the link I was only returned to the starting page for these forums, not to the post itself. And when searching the forums, I find nothing. Could someone please direct me to the other post, or show the code? I tried with the code below, in GameScene…

which pointed to an older errata thread:

> [@Errata for 2D iOS & tvOS Games by Tutorials v1.2](https://forums.kodeco.com/t/errata-for-2d-ios-tvos-games-by-tutorials-v1-2/49/8):
>
> page 299 has the collision mask set to 11 for the seesaw, this makes it collide with the edge which then puts it off centre from the seesawBase. the collision mask should be 3 so that it only collides with the cat and blocks. hope this helps

Though as someone in the question thread pointed out, it is interesting that enabling _Pinning_ with a _Collision Mask_ of `11` works, while the programatic route requires a _Collision Mask_ that excludes `PhysicsCategory.Edge`.

---

<div class="post-metadata">

**Author:** ![darkknightmalta](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/darkknightmalta/32/81494_2.png) [@darkknightmalta](https://forums.kodeco.com/u/darkknightmalta)\
**Post date:** [November 14, 2016, 10:25am UTC](https://forums.kodeco.com/t/chapter-10-challenge-seesaw-joint-by-code/22173/3 "2016-11-14T10:25:12Z")

</div>

> [@Errata for 2D iOS & tvOS Games by Tutorials v1.2](https://forums.kodeco.com/t/errata-for-2d-ios-tvos-games-by-tutorials-v1-2/49/8):
>
> page 299 has the collision mask set to 11 for the seesaw, this makes it collide with the edge which then puts it off centre from the seesawBase. the collision mask should be 3 so that it only collides with the cat and blocks. hope this helps

---

<div class="post-metadata">

**Author:** ![michaelangelo716](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/michaelangelo716/32/81494_2.png) [@michaelangelo716](https://forums.kodeco.com/u/michaelangelo716)\
**Post date:** [November 25, 2016, 11:07pm UTC](https://forums.kodeco.com/t/chapter-10-challenge-seesaw-joint-by-code/22173/4 "2016-11-25T23:07:18Z")

</div>

I’m so glad I checked these forums, wasted over an hour trying to figure out what went wrong. Guess we should double check every step whether it’s in the book or not.

Thanks again!

---

<div class="post-metadata">

**Author:** ![guti](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/guti/32/81494_2.png) [@guti](https://forums.kodeco.com/u/guti)\
**Post date:** [September 18, 2023, 3:35pm UTC](https://forums.kodeco.com/t/chapter-10-challenge-seesaw-joint-by-code/22173/5 "2023-09-18T15:35:03Z")

</div>

jaja You wasted an over an hour, but I spent longer than that. I did wonder about the edge loop physics body being something that kept the seesaw physics body from being partially out of the bounds of the edge loop because on launch, prior to the pin joint set up, the seesaw got pushed inward and not set at the position selected at the scene editor. I did a lot of testing, and research and posting, but I eventually remembered this forum. 😄💯🙌🏾
