{"assets":[{"original":"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2013\/11\/gaem3-300x184.png","local":"\/data\/posts\/2013\/11\/f36de4a299738fac41335b9bbd721803.png"},{"original":"http:\/\/www.ludumdare.com\/compo\/wp-content\/uploads\/2013\/11\/gaem3.png","local":"\/data\/posts\/2013\/11\/2aec08d309918a07d09d1768662d5bb0.png"}],"author_link":"author\/vcover\/","author_name":"tassadar","cat":"LD #28","categories":["LD #28"],"comments":[],"epoch":1385001120,"event":"LD28","likes":10,"metadata":{"p_key":"80460","p_author":"tassadar","p_authorkey":"0","p_urlkey":"289470","p_title":"The quest to reactivate my brain \u2013 Day 3","p_cat":"LD #28","p_event":"LD28","p_time":"1385001120","p_likes":"10","p_comments":"0","p_status":"WAYBACK","us_key":null,"us_name":null,"us_username":null,"event_start":"1386892800","event_key":"20","event_name":"LD28"},"source_url":"2013\/11\/21\/the-quest-to-reactivate-my-brain-day-3\/","text":"<p>As expected, it got late. I got home at around 9pm yesterday and I was completely out of food. So the choice was between rushing to the store to cook something or working on the game. So naturally I fired up Unity.<\/p>\n<p>I took a good look at my approach to collision detection and decided it was quickly becoming too \u201chacky\u201d. For every small problem I tried to avoid, another was popping up. I decided to \u2013 again- remove half the code and try something different. Maybe I could avoid collision altogether if I implemented proper pathfinding first? While researching I found the fantastic<a href=\"http:\/\/arongranberg.com\/astar\/\" target=\"_blank\"> A* pathfinding project<\/a> by\u00a0Aron Granberg, which made a few things much more elegant. I added a Plane behind the 2D scene where I do the pathfinding. The result is a Vector3() array, which awesomely enough is the data structure that iTween uses as a path. So I let the A* algorithm do its thing, call iTween.PutOnPath with the result and let the character move. That will eventually avoid collisions entirely. I say \u201ceventually\u201d because it doesn\u2019t work quite right yet.<\/p>\n<p><a href=\"\/data\/posts\/2013\/11\/2aec08d309918a07d09d1768662d5bb0.png\"><img alt=\"gaem3\" class=\"alignnone size-medium wp-image-300391\" height=\"184\" src=\"\/data\/posts\/2013\/11\/f36de4a299738fac41335b9bbd721803.png\" width=\"300\"\/><\/a><\/p>\n<p>\u00a0<\/p>\n<p>In theory, the box around the counter would tell the A* algorithm that the nodes inside it are not walkable, so the pathfinding should navigate around that. It doesn\u2019t. After tinkering with it until about midnight, the nodes just remained walkable, no matter what I did. I don\u2019t know why, I probably made some stupid mistake. However, this was the point where I had to stop, because I got\u2026 let\u2019s say annoyed. Okay, let\u2019s not say annoyed, let\u2019s say \u201cready to punch a baby seal\u201d. But it wasn\u2019t in vain, because in theory I have a very elegant solution, one I really like. Once this \u201cmake area not walkable\u201d thing starts working. Which it won\u2019t for now, because I\u2019m moving on. Not sure what I\u2019ll work on today, but pathfinding won\u2019t be it, that much I know.<\/p>\n<p>I\u2019ll start a little later than usual today, because I have to go to the grocery store first. I\u2019m super hungry for some reason, it\u2019s almost as if I haven\u2019t eaten anything yesterday. <img alt=\":)\" class=\"wp-smiley\" src=\"http:\/\/ludumdare.com\/compo\/wp-includes\/images\/smilies\/icon_smile.gif\"\/> See you guys tomorrow!<\/p>","time":"November 21st, 2013 2:32 am","title":"The quest to reactivate my brain \u2013 Day 3","title_was_empty":false}