{"action":"created","issue":{"url":"https://api.github.com/repos/godotengine/godot/issues/11879","repository_url":"https://api.github.com/repos/godotengine/godot","labels_url":"https://api.github.com/repos/godotengine/godot/issues/11879/labels{/name}","comments_url":"https://api.github.com/repos/godotengine/godot/issues/11879/comments","events_url":"https://api.github.com/repos/godotengine/godot/issues/11879/events","html_url":"https://github.com/godotengine/godot/issues/11879","id":263387634,"number":11879,"title":"[2.1.4] Collision offset of Area2D when parent is in movement","user":{"login":"charlydelta","id":13337480,"avatar_url":"https://avatars3.githubusercontent.com/u/13337480?v=4","gravatar_id":"","url":"https://api.github.com/users/charlydelta","html_url":"https://github.com/charlydelta","followers_url":"https://api.github.com/users/charlydelta/followers","following_url":"https://api.github.com/users/charlydelta/following{/other_user}","gists_url":"https://api.github.com/users/charlydelta/gists{/gist_id}","starred_url":"https://api.github.com/users/charlydelta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charlydelta/subscriptions","organizations_url":"https://api.github.com/users/charlydelta/orgs","repos_url":"https://api.github.com/users/charlydelta/repos","events_url":"https://api.github.com/users/charlydelta/events{/privacy}","received_events_url":"https://api.github.com/users/charlydelta/received_events","type":"User","site_admin":false},"labels":[{"id":73330064,"url":"https://api.github.com/repos/godotengine/godot/labels/bug","name":"bug","color":"ff2222","default":true},{"id":279097966,"url":"https://api.github.com/repos/godotengine/godot/labels/topic:core","name":"topic:core","color":"ffdd44","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/godotengine/godot/milestones/5","html_url":"https://github.com/godotengine/godot/milestone/5","labels_url":"https://api.github.com/repos/godotengine/godot/milestones/5/labels","id":1449703,"number":5,"title":"2.1","description":"","creator":{"login":"akien-mga","id":4701338,"avatar_url":"https://avatars0.githubusercontent.com/u/4701338?v=4","gravatar_id":"","url":"https://api.github.com/users/akien-mga","html_url":"https://github.com/akien-mga","followers_url":"https://api.github.com/users/akien-mga/followers","following_url":"https://api.github.com/users/akien-mga/following{/other_user}","gists_url":"https://api.github.com/users/akien-mga/gists{/gist_id}","starred_url":"https://api.github.com/users/akien-mga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akien-mga/subscriptions","organizations_url":"https://api.github.com/users/akien-mga/orgs","repos_url":"https://api.github.com/users/akien-mga/repos","events_url":"https://api.github.com/users/akien-mga/events{/privacy}","received_events_url":"https://api.github.com/users/akien-mga/received_events","type":"User","site_admin":false},"open_issues":129,"closed_issues":1298,"state":"open","created_at":"2015-12-08T11:42:22Z","updated_at":"2017-11-02T08:39:58Z","due_on":null,"closed_at":null},"comments":7,"created_at":"2017-10-06T09:34:33Z","updated_at":"2017-11-03T20:14:19Z","closed_at":null,"author_association":"NONE","body":"### **Operating system or device, Godot version, GPU Model and driver (if graphics related):**\r\n\r\n- OS: *Ubuntu 17.04*\r\n- Godot: *2.1.4*\r\n- GPU: unrelated, but *GTX 860m* using the proprietary drivers\r\n\r\n### **Issue description:**\r\n\r\n**The scenario**\r\n\r\n- I have a ship and a player (both `KinematicBody2D`)\r\n- The player can freely move on the ship (player is a child node of ship)\r\n- Ship has a cockpit, player should be able to enter the cockpit to fly the ship\r\n- The cockpit is a `Area2D` to detect a collision (i.e. if the player inside the cockpit, so the 'Action' key triggers the 'player-enters-cockpit' action)\r\n\r\n**The Problem:**\r\n\r\n- In the beginning, ship and player are stationary. Player might move into the cockpit and enter it. Player may then accelerate the ship and jump out. Eventually, he might come back, but cannot enter the cockpit anymore because there is no collision detected by the `Area2D`\r\n- Depending on the velocity of the ship, the actual collision area of the `Area2D` will move ahead of the ship. I.e. there is an offset (see illustration below)\r\n- The higher the velocity, the higher the offset\r\n- If the velocity is constant, the offset is constant as well\r\n- The offset is *always* in the direction of flight. The rotation of the ship is irrelevant\r\n\r\nHere's an illustration (desired/expected place of collision in a moving ship in red on the left, and the actual place of collision in red on the right):\r\n\r\n![dfss](https://user-images.githubusercontent.com/13337480/31276076-514f40b4-aa9a-11e7-8721-193208908ade.png)\r\n\r\n**Worth mentioning**\r\n\r\n- If you enable <kbd>Visible Collision Shapes</kbd> in the debug tools, you won't see any offset at all. The shapes are obviously colliding\r\n- I made a test and manually calculated the collision detection, which produces correct results (i.e. the collisions are detected right, regardless of what the velocity is). A bit more specific: if I check for collision using `collide()` of `RectangleShape2D` for the player model and the `Area2D` inside `_fixed_process()`, I get correct results. However, this is not really practical, since I need to know all possible collision objects in advance... I would expect, that the `body_enter` and `body_exit` events honour the `_fixed_process`-ing (i.e. that the calculations which lead to these events are synchronous with `_fixed_process`)\r\n\r\n```gd\r\nfunc _fixed_process(delta):\r\n    # ...\r\n\r\n    # Workarround\r\n    var player = get_node('../path/to/player')\r\n    var bb_player = player.get_node('collision-model').shape\r\n    var cockpit = get_node('../path/to/cockpit/location')\r\n    var bb_cockpit = cockpit.get_node('collision-model').shape\r\n\t\r\n    if bb_player.collide(player.get_transform(), bb_cockpit, cockpit.get_transform()):\r\n        print('collision')\r\n    else:\r\n        print('no collision')\r\n\r\n    # ...\r\n```\r\n\r\n### **Steps to reproduce:**\r\n\r\n- I made a small demonstration project [right here](https://github.com/charlydelta/godot-movement-cd-bug)\r\n- You can only toggle between two velocities, but it shows the problem quite well I think\r\n- Use <kbd>S</kbd> to travel at a slow velocity (i.e. the hit detection works)\r\n- Use <kbd>F</kbd> to travel at a fast velocity (i.e. the hit detection wont work)\r\n- You can observe the `body_enter` and `body_exit` events in the `print` output\r\n- Traveling at slow speed should indicate `\"ENTERED\"` in the output. If you toggle to a fast speed, you should see, that the player left the cockpit according to the engine (indicated by `\"LEFT\"`)\r\n"},"comment":{"url":"https://api.github.com/repos/godotengine/godot/issues/comments/341814297","html_url":"https://github.com/godotengine/godot/issues/11879#issuecomment-341814297","issue_url":"https://api.github.com/repos/godotengine/godot/issues/11879","id":341814297,"user":{"login":"RandomShaper","id":11797174,"avatar_url":"https://avatars0.githubusercontent.com/u/11797174?v=4","gravatar_id":"","url":"https://api.github.com/users/RandomShaper","html_url":"https://github.com/RandomShaper","followers_url":"https://api.github.com/users/RandomShaper/followers","following_url":"https://api.github.com/users/RandomShaper/following{/other_user}","gists_url":"https://api.github.com/users/RandomShaper/gists{/gist_id}","starred_url":"https://api.github.com/users/RandomShaper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RandomShaper/subscriptions","organizations_url":"https://api.github.com/users/RandomShaper/orgs","repos_url":"https://api.github.com/users/RandomShaper/repos","events_url":"https://api.github.com/users/RandomShaper/events{/privacy}","received_events_url":"https://api.github.com/users/RandomShaper/received_events","type":"User","site_admin":false},"created_at":"2017-11-03T20:14:19Z","updated_at":"2017-11-03T20:14:19Z","author_association":"MEMBER","body":"I'm researching... So far I haven't found a way to fix it."}}
{"actor":{"display_login":"RandomShaper"}}