{"id":289,"date":"2018-06-14T00:20:16","date_gmt":"2018-06-14T05:20:16","guid":{"rendered":"http:\/\/www.chroniclesoftright.com\/blog\/?p=289"},"modified":"2018-06-14T16:23:45","modified_gmt":"2018-06-14T21:23:45","slug":"boar-movement","status":"publish","type":"post","link":"https:\/\/www.chroniclesoftright.com\/blog\/2018\/06\/14\/boar-movement\/","title":{"rendered":"Boar movement"},"content":{"rendered":"<p>I finally got the boars to face the correct way as they are moving around.\u00a0 Sometimes I get a little turned around when I have to do straight up trigonometry, and that&#8217;s what this was.\u00a0 <del>Here&#8217;s what worked (in pseudocode):<\/del><\/p>\n<p><del><code>var o = boarObject;<\/code><\/del><\/p>\n<p><del><code>var currentPosition = ...<\/code><\/del><\/p>\n<p><del><code>var newPosition = ...<\/code><\/del><\/p>\n<p><del><code>var direction = newPosition - currentPosition;<\/code><\/del><\/p>\n<p><del><code>o.rotation.y = Math.atan(direction.x \/ direction.z);<\/code><\/del><\/p>\n<p><del>It took me an embarrassing number of tries to get this right, but it&#8217;s working now.<\/del><\/p>\n<p>***<\/p>\n<p>Edit: After I was\u00a0<strong>sure<\/strong>\u00a0this was working, I fired up Lyridia on my second test machine and it was still completely broken.\u00a0 I fumbled around with it for some time before I found a Stack Overflow post that recommended using <code>lookAt<\/code>.\u00a0 Instead of trying to calculate the rotation myself based on the direction vector, now I just tell each boar object to <code>lookAt(newPosition);<\/code> and it works great.\u00a0 Internally <a href=\"http:\/\/threejs.org\" target=\"_blank\" rel=\"noopener\">THREE.js<\/a> must be doing what I was attempting to do, but the THREE.js code actually works, so I&#8217;m going to let it handle it. \ud83d\ude42<\/p>\n<p>***<\/p>\n<p>I had a few hours in the car today to sort of plan out the next steps for Lyridia.\u00a0 I don&#8217;t want to get into all of it now because it&#8217;s late, but I&#8217;m at the point where some more &#8220;game&#8221; type functionality is going to be added soon, and once there is something for a player to actually do I might start hunting around for alpha testers just to get somebody on the site.\u00a0 Exciting stuff.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I finally got the boars to face the correct way as they are moving around.\u00a0 Sometimes I get a little turned around when I have to do straight up trigonometry, and that&#8217;s what this was.\u00a0 Here&#8217;s what worked (in pseudocode): var o = boarObject; var currentPosition = &#8230; var newPosition = &#8230; var direction =&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-289","post","type-post","status-publish","format-standard","hentry","category-planning-and-development"],"_links":{"self":[{"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/posts\/289","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/comments?post=289"}],"version-history":[{"count":3,"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/posts\/289\/revisions"}],"predecessor-version":[{"id":292,"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/posts\/289\/revisions\/292"}],"wp:attachment":[{"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/media?parent=289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/categories?post=289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chroniclesoftright.com\/blog\/wp-json\/wp\/v2\/tags?post=289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}