{"action":"opened","issue":{"url":"https://api.github.com/repos/godotengine/escoria/issues/201","repository_url":"https://api.github.com/repos/godotengine/escoria","labels_url":"https://api.github.com/repos/godotengine/escoria/issues/201/labels{/name}","comments_url":"https://api.github.com/repos/godotengine/escoria/issues/201/comments","events_url":"https://api.github.com/repos/godotengine/escoria/issues/201/events","html_url":"https://github.com/godotengine/escoria/issues/201","id":335742315,"node_id":"MDU6SXNzdWUzMzU3NDIzMTU=","number":201,"title":"[Feature request] Automatic interact_angle","user":{"login":"mjtorn","id":78427,"node_id":"MDQ6VXNlcjc4NDI3","avatar_url":"https://avatars2.githubusercontent.com/u/78427?v=4","gravatar_id":"","url":"https://api.github.com/users/mjtorn","html_url":"https://github.com/mjtorn","followers_url":"https://api.github.com/users/mjtorn/followers","following_url":"https://api.github.com/users/mjtorn/following{/other_user}","gists_url":"https://api.github.com/users/mjtorn/gists{/gist_id}","starred_url":"https://api.github.com/users/mjtorn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjtorn/subscriptions","organizations_url":"https://api.github.com/users/mjtorn/orgs","repos_url":"https://api.github.com/users/mjtorn/repos","events_url":"https://api.github.com/users/mjtorn/events{/privacy}","received_events_url":"https://api.github.com/users/mjtorn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-26T09:51:23Z","updated_at":"2018-06-26T09:51:23Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"I spent about an hour on something like this, but couldn't get it to work.\r\n\r\nThe idea is that -1 would no longer be \"whatever\" but an indicator that Escoria should calculate the proper angle.\r\n\r\nThis makes the most sense when you have an NPC that moves to a position where the angle doesn't make sense anymore, like the other edge of the viewport.\r\n\r\nAny help would be much appreciated!\r\n\r\nPS.\r\nIt would also be useful to implement a `turn_toward object1 object2` ESC command, especially so that NPCs can be made to face the player when talking to them, like in the case of walking up from behind.\r\n\r\n```diff\r\ndiff --git a/device/globals/player.gd b/device/globals/player.gd\r\nindex cd67dc3..ec48386 100644\r\n--- a/device/globals/player.gd\r\n+++ b/device/globals/player.gd\r\n@@ -158,8 +158,15 @@ func interact(p_params):\r\n                params_queue = p_params\r\n                walk_to(pos)\r\n        else:\r\n-               if animations.dir_angles.size() > 0 && p_params[0].interact_angle != -1:\r\n-                       last_dir = _get_dir_deg(p_params[0].interact_angle)\r\n+               if animations.dir_angles.size() > 0:\r\n+                       if p_params[0].interact_angle != -1:\r\n+                               last_dir = _get_dir_deg(p_params[0].interact_angle)\r\n+                       else:\r\n+                               # var angle = self.get_angle_to(p_params[0].position)\r\n+                               var angle = p_params[0].get_angle_to(self.position)\r\n+                               printt(\"INTERACT ANGLE\", angle, rad2deg(angle) + 180)\r\n+                               last_dir = _get_dir(angle)\r\n+                               printt(\"INTERACT DIR\", last_dir)\r\n                        animation.play(animations.idles[last_dir])\r\n                        pose_scale = animations.idles[last_dir + 1]\r\n                        _update_terrain()\r\n@@ -174,8 +181,14 @@ func walk_stop(pos):\r\n        task = null\r\n        set_process(false)\r\n        if params_queue != null:\r\n-               if animations.dir_angles.size() > 0 && params_queue[0].interact_angle != -1:\r\n-                       last_dir = _get_dir_deg(params_queue[0].interact_angle)\r\n+               if animations.dir_angles.size() > 0:\r\n+                       if params_queue[0].interact_angle != -1:\r\n+                               last_dir = _get_dir_deg(params_queue[0].interact_angle)\r\n+                       else:\r\n+                               var angle = params_queue[0].get_angle_to(self.position)\r\n+                               printt(\"WALK_STOP ANGLE\", angle, rad2deg(angle) + 180, params_queue[0].name)\r\n+                               last_dir = _get_dir(angle)\r\n+                               printt(\"WALK_STOP DIR\", last_dir)\r\n                        animation.play(animations.idles[last_dir])\r\n                        pose_scale = animations.idles[last_dir + 1]\r\n                        _update_terrain()\r\n@@ -201,7 +214,9 @@ func _get_dir_deg(deg):\r\n        var dir = 0\r\n        var i = 0\r\n        for ang in animations.dir_angles:\r\n+               printt(\"\\tLF\", deg, ang)\r\n                if deg <= ang:\r\n+                       printt(\"\\t\\tFOUND\", i)\r\n                        dir = i\r\n                        break\r\n                i+=2\r\n```"}}
{"actor":{"display_login":"mjtorn"}}