{"assets":[{"original":"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2014\/04\/post-mortem-fish-550x340.png","local":"\/data\/posts\/2014\/04\/de29ab2d0d4ff6c68d960187db3bd307.png"},{"original":"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2014\/04\/post-mortem-weed-550x338.png","local":"\/data\/posts\/2014\/04\/64733f86963e047fc7d4f19846d77960.png"},{"original":"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2014\/04\/post-mortem-hook-550x390.png","local":"\/data\/posts\/2014\/04\/f883bbda8983de8a55f3f48f3c9fd5e4.png"},{"original":"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2014\/04\/post-mortem-tentacles-550x378.png","local":"\/data\/posts\/2014\/04\/8085a985d4ca86075c1abc1abaff22a7.png"},{"original":"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2014\/04\/post-mortem-fish.png","local":"\/data\/posts\/2014\/04\/1637936a736fd8fcc7cd57ce66a80918.png"},{"original":"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2014\/04\/post-mortem-weed.png","local":"\/data\/posts\/2014\/04\/2e9977d1a28ab8fd578ec4423097f4ac.png"},{"original":"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2014\/04\/post-mortem-hook.png","local":"\/data\/posts\/2014\/04\/7302ff6c6f977269131a9a2d942b0cec.png"}],"author_link":"author\/danvil\/","author_name":"Danvil","cat":"LD #29","categories":["LD #29"],"comments":[],"epoch":1398784740,"event":"LD29","likes":4,"metadata":{"p_key":"82106","p_author":"Danvil","p_authorkey":"0","p_urlkey":"292838","p_title":"About fish, weed, hooks and tentacles","p_cat":"LD #29","p_event":"LD29","p_time":"1398784740","p_likes":"4","p_comments":"0","p_status":"WAYBACK","us_key":null,"us_name":null,"us_username":null,"event_start":"1398384000","event_key":"22","event_name":"LD29"},"source_url":"2014\/04\/29\/about-fish-weed-hooks-and-tentacles\/","text":"<p>Beneath the surface: my first though was digging, the second underwater. Then I remembered the Beatles song <a href=\"http:\/\/www.youtube.com\/watch?v=3jmdLpsK_k8\">\u201cYellow Submarine\u201d<\/a> and it was clear: I do a submarine treasure hunt game. You can try it <a href=\"http:\/\/www.ludumdare.com\/compo\/ludum-dare-29\/?action=preview&amp;uid=5851\">here<\/a>! For this Ludum Dare I wanted to put an emphasis on creating an immersive environment, so this is what I did (read: \u201ctried\u201d).<\/p>\n<p><strong>Fish:<\/strong><\/p>\n<p><a href=\"\/data\/posts\/2014\/04\/1637936a736fd8fcc7cd57ce66a80918.png\"><img alt=\"post mortem fish\" class=\"alignnone size-large wp-image-357531\" height=\"340\" src=\"\/data\/posts\/2014\/04\/de29ab2d0d4ff6c68d960187db3bd307.png\" width=\"550\"\/><\/a><\/p>\n<p>Some years ago I experimented with <a href=\"http:\/\/en.wikipedia.org\/wiki\/Swarm_behaviour\">swarm behaviour<\/a> and there is even an algorithm called <a href=\"http:\/\/en.wikipedia.org\/wiki\/Particle_swarm_optimization\">particle swarm optimization<\/a> which I used once. A quick 3D model of a fish with Blender a uniform orange material and we have a fish GameObject. Then a second GameObject for the swarm which moves the fish in sync. Each fish is pulled towards to the common swarm goal and pushed away from other fish in the swarm \u2013 ready.<\/p>\n<p><strong>Weed:<\/strong><\/p>\n<p><a href=\"\/data\/posts\/2014\/04\/2e9977d1a28ab8fd578ec4423097f4ac.png\"><img alt=\"post mortem weed\" class=\"alignnone size-large wp-image-357551\" height=\"338\" src=\"\/data\/posts\/2014\/04\/64733f86963e047fc7d4f19846d77960.png\" width=\"550\"\/><\/a><\/p>\n<p>While the ocean floor is actually <a href=\"http:\/\/www.youtube.com\/watch?v=x2X6H1llkb0\">extremely empty down there <\/a> (did you see that ghost shark!), I figured some plants would look nice. First I tried a blender model, but quickly switched to procedural generation. Weed is created dynamically in batches of around 100 halms. Each halm is created as simple pyramid with 3 radial and height segments. At each height segment there is noise added and the halm bends a little to created the rigged effect.<\/p>\n<p><strong>Hooks:<\/strong><\/p>\n<p>Now how to pick up treasure from the floor. A hook for grasping and pulling\u00a0the treasure in would be nice. But how to do that in Unity3D? After some failed atempts I created a spring joint on the submarine object which is attched to a hook mesh. If the \u201cMax Distance\u201d property of the spring joint is increased\/decreased the hook is lowered or pulled in. To pick up objects I use a dynamically created \u201cFixed Joint\u201d to connect the grappeld object to the hook. The rope is a dynamically created cylinder where one end is on the submarine and the other on the hook.<\/p>\n<p><a href=\"\/data\/posts\/2014\/04\/7302ff6c6f977269131a9a2d942b0cec.png\"><img alt=\"post mortem hook\" class=\"alignnone size-large wp-image-357553\" height=\"390\" src=\"\/data\/posts\/2014\/04\/f883bbda8983de8a55f3f48f3c9fd5e4.png\" width=\"550\"\/><\/a><\/p>\n<p><strong>Tentacles:<\/strong><\/p>\n<p>Motivated by the hook physics I aimed for something bigger: evil tentacles which grap your submarine and drag you down. I used four cylinders connected with hinge joints, a fixed base cube and a sphere as a endeffector. But moving the endeffector in a controled way from A to B is not a trivial task. The tentacle tends to mess up and get stuck in itself. Time for some\u00a0<a href=\"https:\/\/bitbucket.org\/Danvil\/ld29_beneath\/src\/50173a80339818b715c825d16f73b49a529913b9\/Assets\/AI\/Tentacle.cs?at=master\">math magic<\/a> (line 136) and please don\u2019t ask\u2026 In the end the tentacle gets stuck sometimes, sometimes it moves a bit erratically, but in total I am quite satisfied with the result.<\/p>\n<p>It can hoard treasure too:<\/p>\n<p><a href=\"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2014\/04\/post-mortem-tentacles.png\"><img alt=\"post mortem tentacles\" class=\"alignnone size-large wp-image-357559\" height=\"378\" src=\"\/data\/posts\/2014\/04\/8085a985d4ca86075c1abc1abaff22a7.png\" width=\"550\"\/><\/a><\/p>\n<p>You can play my entry <a href=\"http:\/\/www.ludumdare.com\/compo\/ludum-dare-29\/?action=preview&amp;uid=5851\">here<\/a>! Please let me know what you think in the comments!<\/p>","time":"April 29th, 2014 3:19 pm","title":"About fish, weed, hooks and tentacles","title_was_empty":false}