The 100 hour deadline is part business—as this is unlikely to make any money, I probably shouldn’t spend that much time on it—and part creative—having a time constraint will force me to make faster decisions and to not second guess them.
Day 1—Ideas and Concepts
I already had an idea coming in to this project and so I fired up Procreate on my iPad and sketched out the basic concept and quickly realised that it’s way too complicated for this project.
Scrapping that (for the moment), I spent the next thirty minutes mind mapping new ideas and landed on a coin flip game.
The game loop is simple: tap the screen to flip a coin in the air, then tilt the device left or right to catch it in a position suitable for flipping again. Points are awarded for successful catches.
I wanted to experiment with Inverse Kinematics for a realistic thumb movement, and here’s where I hit my first snag.
Getting the IK set up in Xcode was really easy using the scene editor, as was having it reach for a node. In the image below, the green node was the target node and the blue rectangle represented the end effector.
I added this to
let targetNode = childNodeWithName("target")
let action = SKAction.reachToNode(targetNode!, rootNode: knuckleNode, duration: 0.1)
And this to
let action = SKAction.reachTo(CGPoint(x: 1100, y: 168), rootNode: knuckleNode, velocity: 5000)
This gave me the exact behaviour I was looking for. A nice, realistic flicking motion. The blue “fingernail” node was given a static physics body that interacted with the yellow coin’s dynamic physics body. The collisions worked as expected and it was all looking good until it came to the actual flicking motion.
Unfortunately, it appears that using the
reachTo actions does not update the velocity of its physics body, so no momentum is applied to the other objects that it interacts with.
didSimulatePhysics method and printing out the velocity of the fingernail node after every update confirmed that there was no velocity during the movement, so none got applied to the coin when the thumb flipped up and it ended up unrealistically stuck to the fingernail.
The two alternative options I’ve come up with are to try and fake it using the collision delegate and applying an appropriate impulse at the end of the thumb motion, or to abandon IK and use a mixture of constraints and joints.
I have posted a question on SA for some guidance and I’ll experiment with these options tomorrow.
If you you enjoyed this, sign up to my mailing list to get my latest posts direct to your inbox.Your email won't be shared and you can unsubscribe any time (the link’s at the bottom of every email).