Just one minute while I learn how Ienumerators work...

eughh... so last time I casually mentioned how I'd like the rope to extend from the player to its target, instead of just instantly appearing there. I thought it would be a couple of simple lines of code.

It wasn't.

So in the end I had to learn how Ienumerators worked. It was about time anyway, I'd just been using them in other projects for time delays and such. I never really understood what they were, turns out they're actually quite useful. 

Before I was using a mess of nested If statements, and digging my way through it with each click of the mouse. Like a mother digging through her childs' bowl of spaghetti, desperately looking for her Swarovski earrings. The new Ienumerator script is much simpler. 

Ienumerators seem to allow coding to be thought of more as "flowchart logic" instead of the borderline personality disorder that most computers suffer from. This is largely due to the yield statement which allows code to run frame by frame. I put any coding segments requiring movement of the player or the rope inside Ienumerators and ran them with yield return new WaitForFixedUpdate. This also inadvertently solved many of the other problems I'd been having with the script.

I ended up with something like this eventually: 


if (touch/click) {

            *raycast toward mouse click*
            if (hit.collider != null) {
                StartCoroutine (hookshot (out TARGET)); *where TARGET is 
                equal to the raycast hit.point*
    IEnumerator hookshot (TARGET) {
        while (touch/clickhelddown) {
        * shoot the rope towards the TARGET*
        yield return new WaitForFixedUpdate();
            if (rope makes it to TARGET) {
                *turn gravity off*
                StartCoroutine (hookHit (TARGET));
        *turn gravity back on and get rid of the rope*

    IEnumerator hookHit (TARGET) {
        while (touch/clickhelddown)  {
            *move Player towards TARGET*
            yield return new WaitForFixedUpdate();
        *turn gravity back on and get rid of the rope*

It was important to use vector2.movetowards for the movement of the rope itself to get a guaranteed speed and direction. However when the rope is pulling the character towards its strike point addForce is used as this is physics based movement. By using physics the momentum of the player can be conserved allowing for that tarzan-like swing effect.

I know Ienumerators aren't the most interesting subject but it was nice to finally find something that feels like it works for the movement script. I also edited the camera script to only track the x movement so the camera doesn't move up and down with the player.

Lastly, I started working on a script to randomly instantiate obstacles in the path of our character. Currently the obstacles are represented by small circles, but eventually I feel like they will be peacocks to fit with one of our main tenements of a good video game: poultry must feature heavily. I got the starting script by following along with this video:


really great work "Unity"

I'm using the script as a base to build off, I'm probably not going to instantiate based off time, but rather distance, and i'll probably add some extra levels of randomness in their because i'm craaaazzzy like that.