You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OS/device including version:
Windows 10 Pro 64 bit (latest updates including May 2020 patch)
GTX 980 (Nvidia driver 452.06)
OpenGL ES 2.0
Issue description:
What happened: Area2D being detected on same frame as movement but KinematicBody2D not detected until the following frame.
Expected: Area2D signals area_entered and body_entered to fire on the same frame
Steps to reproduce:
Create a new 2D scene
Add a KinematicBody2D to the scene (named "MovingBody"), global position at x=screen width / 3, y=screen height / 2, with a rectangle collision shape sized 64x64
Add an Area2D to MovingBody (named "InteractArea") local position at x=0, y=0, with a rectangle collision shape sized 64x64
Create and add a script to MovingBody named MovingBody.cs, extending KinematicBody2D
Connect the following signals (on InteractArea) to the methods:
area_entered
area_exited
body_entered
body_exited
Add an Area2D to the scene (named "InteractableArea"), global position at x=(screen width / 3) * 2, y=screen height / 2, with a rectangle collision shape sized 32x32
Create and add a script to InteractableArea named InteractableArea.cs, extending Area2D
public class InteractableArea : Area2D
{
[Export] public Vector2 Velocity { get; set; } = Vector2.Zero;
public override void _PhysicsProcess (float delta)
{
base._PhysicsProcess(delta);
Translate(Velocity * delta);
}
private void OnAreaEntered (Area2D area) =>
GD.Print($"InteractableArea -> Area entered: {area.Name}");
private void OnAreaExited (Area2D area) =>
GD.Print($"InteractableArea -> Area exited: {area.Name}");
private void OnBodyEntered (PhysicsBody2D body) =>
GD.Print($"InteractableArea -> Body entered: {body.Name}");
private void OnBodyExited (PhysicsBody2D body) =>
GD.Print($"InteractableArea -> Body exited: {body.Name}");
}
Connect the following signals (on InteractableArea) to the methods:
area_entered
area_exited
body_entered
body_exited
Set the Velocity of MovingBody to x=1024, y=0 and set the Velocity of InteractableArea to x=0, y=0
9a) Set the following collision layer and mask flags:
MovingBody: Layer 1, Mask none
InteractArea: Layer 2, Mask 3
InteractionArea: Layer 3, Mask 1 and 2
Create a new script called Ticker.cs and add it to the scene node
Set the scene node to "Process" on paused, and set MovingBody and InteractableArea to "Stop"
Add the following code to Ticker.cs:
using Godot;
public class Ticker : Node2D
{
private bool m_wasDoFrame = false;
private bool m_isDoFrame = false;
private float m_frameCounter = 0;
public override void _Ready ()
{
base._Ready();
GetTree().Paused = true;
}
public override void _PhysicsProcess (float delta)
{
base._PhysicsProcess(delta);
if (m_isDoFrame)
{
m_isDoFrame = false;
m_wasDoFrame = true;
m_frameCounter++;
GD.Print($"Frame counter: {m_frameCounter}");
GetTree().Paused = false;
}
else if (m_wasDoFrame)
{
m_wasDoFrame = false;
GetTree().Paused = true;
}
}
public override void _Input (InputEvent @event)
{
base._Input(@event);
if (@event.IsActionReleased("ui_accept")) m_isDoFrame = true;
}
}
Start the scene. MovingBody should be on the left and InteractableArea should be on the right, and when "ui_enter" is pressed the game should do one physics tick then pause, while outputting the frame count and any interactions or any fired signals:
If the MovingBody's Velocity is Zero but the InteractableArea's Velocity is x=-1024, y = 0 then when they overlap the signals fire as expected. I have tried putting "ForceUpdateTransform()" near enough everywhere and re-ran at different points with no use. The X speed does not need to be 1024 but in this example it works well as on one frame it is not overlapping at all then the following frame the InteractableArea is overlapped nicely to show th effect (the area being detected as overlapping on the same frame as the movement but the body not being detected until the following frame). I have read that the bodys are all moved at once but I thought that ForceUpdateTransform() would help this?
The text was updated successfully, but these errors were encountered:
If this is intended, get_overlapping_bodies() shouldn't point to the signal, because they both work the same. But IMO signal should be emitted immediately or at least there should be a way to do so.
Does anyone know why the area_enetered signal doesn't fire immediately? My best guess is that, the rigid body does check for overlap every frame, whereas the area does not (if this is true, how often is it running this / what controls that?)
For the area_entered signal, it seems to be checked on Area2D::_area_inout
Which itself runs on the physics server's area_set_area_monitor_callback
I wonder if it makes sense to allow running the area's monitoring on body_set_state_sync_callback as well? Is there a reason why it's not already doing that (and what explains the few frames of delay? it seems to be between 2 and 4 frames in my test).
Godot version:
3.2.2 C#/Mono 64 bit
OS/device including version:
Windows 10 Pro 64 bit (latest updates including May 2020 patch)
GTX 980 (Nvidia driver 452.06)
OpenGL ES 2.0
Issue description:
What happened: Area2D being detected on same frame as movement but KinematicBody2D not detected until the following frame.
Expected: Area2D signals area_entered and body_entered to fire on the same frame
Steps to reproduce:
9a) Set the following collision layer and mask flags:
Minimal reproduction project:
GodotTest.zip
Minor addition:
If the MovingBody's Velocity is Zero but the InteractableArea's Velocity is x=-1024, y = 0 then when they overlap the signals fire as expected. I have tried putting "ForceUpdateTransform()" near enough everywhere and re-ran at different points with no use. The X speed does not need to be 1024 but in this example it works well as on one frame it is not overlapping at all then the following frame the InteractableArea is overlapped nicely to show th effect (the area being detected as overlapping on the same frame as the movement but the body not being detected until the following frame). I have read that the bodys are all moved at once but I thought that ForceUpdateTransform() would help this?
The text was updated successfully, but these errors were encountered: